jquery function is not calling for new added ajax data
<p>Here user is adding comment on a message. ajax call is used to add comment in database then comment is displayed to jsp page.</p>

<p>For each comment there is a delete button problem is that new added ajax comment is not calling the delete jquery method. If I refresh the page then after it is calling the delete method.</p>

<p>I want that newly added ajax comment's delete method should call without page refresh.</p>

<p>ajax call to add comment (working properly adding data to DB and shoing in jsp page)</p>

<pre><code>$('.commentbox').on('keydown', function(event) {
        parentId=$(this).parent().attr("id");

        var idis='#'+parentId;
        var commentOn = $(idis).find('input[name="commentOn"]').val();
        var commentIs = $(idis).find('textarea[name="commentbox"]').val();
        var dataString1 = 'commentOn='+ commentOn
            +'&amp;comment='+commentIs;
        $("#comment").val('');
        event.preventDefault();
        $.ajax({   
            type: "POST",   
            url: "addmessagecomment", 
            dataType: "text html",
            data: dataString1,   
            success: function(data) { 
                var divtoadd="#comments_"+commentOn;
                $(divtoadd).append(data); 
                $(idis).find('textarea[name="commentbox"]').val("");
            }     
        }); 
    }); 
</code></pre>

<p>for deleting the comment( not calling on new added ajax comment work after page refresh)</p>

<pre><code>$('.deletecomment').click(function (f){

        var parentId=$(this).parents('.single_comment').attr('id');
        var todel=parentId.replace("comment_","");
        $.post('deletecomment?commentId='+todel, function(data) {
            $('#'+parentId).remove();

        });

    });
</code></pre>
