Sunday, 18 August 2013

I can't select appended element before reload page in query

I can't select appended element before reload page in query

this function append elements : ! i need select a.commentdelete tag before
reloading page!!!
enter code here
var item = "<a class='commentdelete' id='";
item += '95';
item += "'>delete</a>";
var maindiv = '#'+module_id;
//alert(maindiv);
$(maindiv).append($("<div class='commentdiv'></div>")
.html(item)
.fadeIn('slow'));
i need to select one of elements that appended before reload page by this
code:
$('.commentdelete').click(function(e){
e.preventDefault();
var comment_id = $(this).attr('id');
alert();
//deleteComment_ajax(user, comment_id);
location.reload();
});

No comments:

Post a Comment