0

编码 :

 $(".postAnswer").livequery("click", function (event) {


    appendControl($(this));
    event.preventDefault();


});

此代码块位于 document.ready 函数中。我在这里尝试做的是,每次单击“.postAnswer”按钮时,都会调用一个 ajax 并返回 html,然后将其附加到父级。返回的 html 包含具有“.postAnswer”类的相同链接按钮,我正在使用 livequery 绑定新附加控件的事件。

在上面的代码中,click 事件是在单击文档的任意位置时触发的。需要一些帮助来解决这个问题。

谢谢

编辑

问题解决了 ...

4

1 回答 1

0
$("a").live("click", function (e) {

    e.preventDefault();
    var id = $(this).attr("id");

    if (id == "Like") likeAnswer(this);

    else if (id == "insertPost") appendControl(this);


});

我就是这样改回来的。现在工作正常。

于 2011-12-25T08:39:20.563 回答