如何将效果仅应用于新添加的节点(jQuery)

时间:2009-10-14 01:31:35

标签: jquery

我通过AJAX加载html并将其附加到DIV但是我希望能够选择新加载的html并将hide()。fadeIn()应用于新添加的html中的元素。

当前功能看起来像这样

wall = new Object();

wall.showWall = function (options) {
    // Use this to initiate the comment wall
    $.ajax({
        url: "activity_results.html?"+options,
        cache: false,
        success: function(html){
            $("#comments .loader").hide(); // The wall's comment spinner
            requestStuff.showResponse(); // Trigger the addComment function
            if (!options){ // Make sure we are not paging
                wall.showMore();
            }
            $("#comments").append(html).hide().fadeIn("slow");
        }
    });

}

当新的html加载到#comments中时,我希望只能淡入这些节点。

2 个答案:

答案 0 :(得分:0)

不是附加到#comments而是在其中创建隐藏的div并将其附加到该div。

然后隐藏div的fadeIn

答案 1 :(得分:0)

$(html).appendTo("#comments").hide().fadeIn("slow");