【发布时间】:2012-05-21 01:19:47
【问题描述】:
我附加了从 Ajax 接收的数据,它还包含一个带有 bsubmit 类的分区。 当页面加载时,如果我单击包含类 bsubmit 的 div,则会执行以下函数但是当我单击也包含类 bsubmit 的新附加数据时,则以下代码不起作用。
这里是代码
$(function() {
$(".bsubmit").click(function() {
var id = $(this).parent().parent().attr("id");
var comm= document.getElementById(id).getElementsByClassName("commentadd")[0].value;
$.ajax({
type: "POST",
url: "comment.php",
data: {id:id, comm:comm},
cache: false,
success: function(data){
$('.addcomment').slideUp('slow', function() {
});
// Bottom Line not working
$("#"+id).find(".item_comment").append(data); // DATA Contains a div with class bsubmit
$(data).appendTo("#"+id).find(".item_comment"); // Now these Appended Div isnt calling this function again, Why ? I want to call them again
$('#load').fadeOut();
}
});
return false;
});
});
【问题讨论】:
-
无法理解您希望重新执行的功能。
-
@VisioN。他认为
appendTo返回父级,它没有...... -
你希望发生什么,不发生什么。
-
@gdoron 哈!你看到更新了吗? :)
-
@VisioN - 当页面加载时,如果我点击包含类 bsubit 的 div,下面的函数会执行但是当我点击新的附加数据时,它也包含类 bsubmit 那么下面的代码不是工作。
标签: php jquery ajax jquery-selectors simple-html-dom