我想做一个按钮来启动点击,让随机数字继续运行,(使用)
- or 2. to call) but if I press it , the error message shows that "Uncaught
引用错误: 横线阵列没有定义”但数字上方仍在运行, 我无法
了解哪里是错误的地方。
但是如果我用3个,它正常工作。
恶心! Thx!
我3岁时尝试的全代码是 http://jsfiddle.net/eVyjC/
function computeRandom(){
// skip code: have used loop to create six spans already
var spanArray = document.getElementsByTagName("span");
//1.document.write("<input type = button value = start onclick = "passKeepMove(value,spanArray) " name = button1>");
//2.document.write("<input type = button value = start onclick = "setInterval(function(){keepMove(value,spanArray);}, 10) " name = button1>");
//3.setInterval(function(){keepMove(value,spanArray);}, 10) ;
}
function keepMove(val,sp){//call by pointer
var index = parseInt(Math.random()*43);//set a increment to avoid repeatition
for( i = 0; i < sp.length; i++){
sp[i].innerHTML = val[i+index];
}
}
function passKeepMove(v,s){
setInterval(function(){keepMove(v, s);}, 10);
}