2 u011627481 u011627481 于 2016.09.25 17:27 提问

书上的bingoCard哪里出错了

Click here

window.onload=initAll;
var usedNum = new Array(76);
function initAll(){
//-----------检查浏览器是否支持js
if (document.getElementById){
document.getElementById("reload").onclick = anotherCard;
newCard();
}
else {
alert("Sorry,your broeser doesn't support this script")
}

}
function newCard(){
for (var i=0;i<24;i++){
setSquare(i);
}
}

function setSquare(thisSquare){

var currSquare = "square" + thisSquare;
var colPlace = new Array(0,0,0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,4);
var colBasis = colPlace[thisSquare] * 15;
var newNum;
do{
    newNum = colBasis + getNewNum() + 1;
}
while(usedNum[newNum]);

usedNum[newNum]=true;
document.getElementById(currSquare).innerHTML = newNum;

}

function getNewNum(){
return Math.floor(Math.random() * 15);
}

function anotherCard(){
for (var i=1;1<usedNum.length;i++){
usedNum[i]=false;
}
newCard();
}

click之后就崩了

1个回答

devmiao
devmiao   Ds   Rxr 2016.09.26 01:03
Csdn user default icon
上传中...
上传图片
插入图片