标签:callback
HTML结构:
<p id="w1"></p> <p id="w2"></p>
/* lines words */ var w1 = '时光是琥珀', w2 = '泪一滴滴被反锁' w3='情书再不朽', w4='也磨成沙漏', w5='青春的上游', w6='白云飞走苍狗与海鸥', w7='闪过的念头', w8='潺潺的溜走'; /* show page 1 words */ showWord(w1,document.getElementById('w1'),0,function(){ showWord(w2,document.getElementById('w2'),0,null); }); /* show function */ function showWord(word,objID,i,callback){ var wlen = word.length; objID.innerHTML += word[i]; i++; setTimeout(function(){ if(i < wlen) { showWord(word, objID, i, callback); }else if(i == wlen){ callback(); } },300); }
标签:callback
原文地址:http://blog.csdn.net/wuweitiandian/article/details/43267951