代码:
$(".postAnswer").livequery("click", function (event) {
appendControl($(this));
event.preventDefault();
});
此代码块位于document.ready函数内。我在这里要做的是,每次单击“.postAnswer”按钮,都会调用一个ajax,然后返回html,然后将其附加到父级。返回的html包含相同的链接按钮,其类为“.postAnswer”,我使用livequery绑定新追加控件的事件。
在上面的代码中,click事件在文档的任何位置单击时触发。需要一些帮助来解决这个问题。
由于
修改
问题已解决......
答案 0 :(得分:0)
$("a").live("click", function (e) {
e.preventDefault();
var id = $(this).attr("id");
if (id == "Like") likeAnswer(this);
else if (id == "insertPost") appendControl(this);
});
这就是我改变它的方式。现在工作正常。