如何以500毫秒的间隔fadeIn()表行

问题描述 投票:0回答:1

下面的代码获取一段包含一定数量行的html。其中一些行是newentry类。 (class="newentry")我期待我的代码以1000米延迟显示它们,但它们都同时出现。为什么setTimeout不会在每次调用每行fadeIn()之间等待?

$.ajax({
    url: "@{Live.live(event.mnemonic)}",
    success: function(data) {
        var wait =0;
        $("#results").html(data);

        wait =500;
        $(".newentry").each(function(){
            setTimeout(function() { $('#'+this.id).fadeIn(); }, wait);
            wait += 1000;
        });

        }
        setTimeout('tick()', 1700-wait);
    }
});
ajax settimeout fadein
1个回答
0
投票

试试这个

$(".newentry").hide(); 
$.ajax({
    url: "@{Live.live(event.mnemonic)}",
    success: function(data) {
        $("#results").html(data);
        i=500;
        $('.newentry').each(function(){
            setTimeout(function(){delayedShow($(this))},i);
            i=i+500;
        });
        {
    } 
}); 
function delayedShow(obj) { obj.fadeIn(); }
© www.soinside.com 2019 - 2024. All rights reserved.