2012-01-06 112 views
0

怎麼可能用jquery each()逐個顯示循環元素,比如有一個延遲?用jquery顯示循環元素用一個一個來顯示

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++; 
    }); 

} 
+0

[Jquery的。每個()包括找乾淨的代碼的延遲(可能重複http://stackoverflow.com/questions/4143308/jquery - 每一個 - 包括-A-延遲找換乾淨的代碼) – Matt 2012-01-06 11:56:09

回答

0

嘗試使用.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++; 
    }); 

}