【问题标题】:Display looped elements on by one with Jquery使用 Jquery 逐个显示循环元素
【发布时间】:2012-01-06 11:53:43
【问题描述】:

如何使用 jquery each() 一个一个地显示循环元素,比如之间有延迟?

function text_animate(){


    var get_text=$("#animated_text_falling h1").text();
    var words =get_text.split(" ");
    $("#animated_text_falling h1").remove("h1");
    var wordCount = 0;
        $.each(words, function(key, value) { 



    var $word= $('<div id= word_' + key + '>' + value + '</div>').appendTo('#animated_text_falling').show();

    //here somhow to show $('<div id= word_' + key + '>' + value + '</div>') with delay

    wordCount++;
    });

}

【问题讨论】:

标签: jquery


【解决方案1】:

尝试使用 .delay()

function text_animate(){


    var get_text=$("#animated_text_falling h1").text();
    var words =get_text.split(" ");
    $("#animated_text_falling h1").remove("h1");
    var wordCount = 0;
    var delayCount = 0;
        $.each(words, function(key, value) { 

delayCount = delayCount + 1000;

    var $word= $('<div id= word_' + key + '>' + value + '</div>').appendTo('#animated_text_falling').delay(delayCount).show();

    //here somhow to show $('<div id= word_' + key + '>' + value + '</div>') with delay

    wordCount++;
    });

}

【讨论】:

    猜你喜欢
    • 2014-01-08
    • 2018-06-05
    • 2010-09-15
    • 1970-01-01
    • 2021-02-23
    • 2017-10-07
    • 2017-01-06
    • 1970-01-01
    相关资源
    最近更新 更多