可能有点令人困惑 :S
如果有人可以帮我将一个字符串数组分割成字母,然后按时间间隔打印出来。就像在DOS中一样。
我可以对单个字符串执行此操作,但无法对数组执行此操作。
这是我的代码:
var text = new Array();
text[0] = "welcome ".split('');
text[1] = "how are u?".split('');
var delay = 20;
for (var j = 0; j < text.length; j++) {
var txt = text[j];
for (u = 0; u < txt.length; u++) {
setTimeout(function () {
$('div#console_div').append('<br />' + txt.shift());
}, delay * j + 100);
}
}