【问题标题】:How do I fadeIn() table rows with 500ms interval如何以 500 毫秒间隔淡入()表行
【发布时间】:2014-07-02 12:58:57
【问题描述】:

下面的代码获取一段包含一定行数的 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】:

    试试这个

    $(".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(); }
    

    【讨论】:

    • 谢谢,但我想做的不是一次显示所有行。所以对整个类集进行淡入并不是很好。
    • @user3797731 编辑代码,看看是否适合你的追求
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多