[英]Typing Text effect not working
I'm writing a script to take an array of strings, split them by characters, and print them out to the screen. 我正在编写一个脚本,以获取字符串数组,按字符将其拆分,然后将其打印到屏幕上。 This is what I have and for some reason it is not doing anything.
这就是我所拥有的,由于某种原因它什么也没做。 Any ideas?
有任何想法吗?
function autowrite() {
var write_text=["Your Memories","Your Thoughts","Your Photos"];
var split_text = Array();
var i;
var c;
for(i=0; i < write_text.length; i++)
{
split_text[i] = write_text[i].split("");
for(c=0; i < split_text.length[i]; i++)
{
alert(split_text[i][c]);
}
}
}
Your second loop is using the variable from the first loop. 您的第二个循环正在使用第一个循环中的变量。
You need to check and increment c
, not i
. 您需要检查并增加
c
,而不是i
。
Also, the expression split_text.length[i]
is wrong; 另外,表达式
split_text.length[i]
是错误的; you need to get the i
th element of the split_text
array, not of the length
property. 您需要获取
split_text
数组的第 i
个元素,而不是length
属性。
Change it to 更改为
for(c=0; c < split_text[i].length; c++)
for(c=0; i < split_text.length[i]; i++)
{
alert(split_text[i][c]);
}
replace i with c in i < and i++ and split_text.length[i]; 在i <和i ++中将c替换为i,然后split_text.length [i]; with split_text[i].length;
与split_text [i] .length;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.