此函数追加元素: !我需要在重新加载页面之前选择a.commentdelete标签!!!
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'));
我需要选择一个在重新加载页面之前附加的元素:
$('.commentdelete').click(function(e){
e.preventDefault();
var comment_id = $(this).attr('id');
alert();
//deleteComment_ajax(user, comment_id);
location.reload();
});
答案 0 :(得分:2)
怎么样:
$(document).on("click", '.commentdelete', function(e){
//do work
});