所以这里就是我这样做的远:的JavaScript - for循环使用数组
<script>
text = new Array("t", "te", "tes", "test");
for(new i; i < text.length; i++)
{
document.getElementById('text').innerHTML=text[i];
}
</script>
<body>
<span id='text'></span>
</body>
我将在以后添加计时器,但我的问题是,为什么会“的ReferenceError“我' 没有定义”? 它被定义为你可以看到.. 在此先感谢。
您使用'var'关键字声明一个变量。 [JavaScript 101](http://hsablonniere.github.io/markleft/prezas/javascript-101.html)。 – undefined
注意:你通常应该使用[数组文字符号](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals#Array_literals)而不是'new Array( )'。在你的情况下,这看起来像'var text = ['t','te','tes','test'];'。 –
Matt,那有什么关系?只是好奇。 – prk