jQuery事件处理程序不处理附加元素

fdi*_*tto 0 jquery

我正在发送ajax请求,我已将结果附加到div上.在此追加之后,如果我想点击附加的链接(exec jquery点击功能),为什么点击功能doesen't工作?(抱歉英文不好:P)

编辑:

jQuery('.more').live("click",function() {
    var ID = jQuery(this).attr("id");
    if(ID) {
        jQuery("#more"+ID).html('<img src="template/css/images/moreajax.gif" />');
    jQuery.ajax({
        type: "POST",
        url: "loadmore.php",
        data: "lastid="+ ID, 
        cache: false,
        success: function(html){
            $("#contentWall").append(html);
        jQuery("#more"+ID).remove(); // removing old more button
        }
    });
    } else {
        jQuery(".morebox").html('The End');// no results
    }
return false;
});
Run Code Online (Sandbox Code Playgroud)

Ja͢*_*͢ck 6

您需要使用.live().on()取决于您的jQuery版本才能使用.

常规.click()仅适用于当前在DOM中的元素,而不适用于将来添加的元素.