function change(id){
var temp = parseInt(id);
var row = temp/10;
var col = temp-(temp/10)*10
if(minearray[row][col]==0)
{
document.getElementById(id).className="buttonstyle2";
}else{
document.getElementById(id2).value=id;
}
if((row+1)<=7&&(col+1<=7)&&minearray[row+1][col+1]==0){
var id2int = (row+1)*10+(col+1)
var id2 = id2int.toString();
//document.getElementById(id2).className="buttonstyle2";
document.getElementById(id2).value=id2;
change(id2);
}
}
var temp = parseInt(id);
var row = temp/10;
var col = temp-(temp/10)*10
if(minearray[row][col]==0)
{
document.getElementById(id).className="buttonstyle2";
}else{
document.getElementById(id2).value=id;
}
if((row+1)<=7&&(col+1<=7)&&minearray[row+1][col+1]==0){
var id2int = (row+1)*10+(col+1)
var id2 = id2int.toString();
//document.getElementById(id2).className="buttonstyle2";
document.getElementById(id2).value=id2;
change(id2);
}
}
var temp = parseInt(id);
var row = temp / 10;
var col = temp - (temp / 10) * 10
if(minearray[row][col] == 0) {//数组minearray 声明呢?
document.getElementById(id).className = "buttonstyle2";
} else {
document.getElementById(id2).value = id;//id2 哪定义的?
}
if((row + 1) <= 7 && (col + 1 <= 7) && minearray[row + 1][col + 1] == 0) {
var id2int = (row + 1) * 10 + (col + 1)
var id2 = id2int.toString();
//document.getElementById(id2).className="buttonstyle2";
document.getElementById(id2).value = id2;
change(id2);
}
}楼主贴全点吧。
存储这个状态值很多办法。直接存储在元素的节点上可以
document.getElementById(元素ID).setAttribute("status","0");js中建一个对象来存储也可以
var status={};然后将元素的id[如果id不重复的话]当成标识来存放:status[元素ID]=0;当然不一定是元素ID,也可以是任意一个你能快速或直接获取到的不重复的属性,比如它的索引值,都行