2012-01-06 5 views
0

どのようにjquery each()を使用してループした要素を1つずつ表示することができますか?ループされた要素をJqueryで1つずつ表示する

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の.each()]の可能重複http://stackoverflow.com/questions/4143308/jqueryクリーンコードのための遅延を含む) – Matt

答えて

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

} 
関連する問題