为了账号安全,请及时绑定邮箱和手机立即绑定

js沒反應

var nextData = [

[0, 0, 0, 0],

[0, 0, 0, 0],

[0, 2, 0, 0],

[0, 2, 2, 0]

];

var gameData = [

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 1, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 1, 1, 1, 1, 0, 0]

];

var nextDivs = [];

var gameDivs = [];

var initGame = function() {

for(var i=0; i<gameData.length; i++) {

var gameDiv =[];

for (var j=0; j<gameData[0].length; j++) {

var newNode = document.createElement('div');

newNode.className = 'nene';

newNode.style.top = (i*20) + 'px';

newNode.style.left = (j*20) + 'px';

document.geElemetById('game').appendChild(newNode);

gameDiv.push(newNode);

}

gameDivs.push(gameDiv);

}

}

var initNext = function() {

for(var i=0; i<nextData.length; i++) {

var nextDiv =[];

for (var j=0; j<nextData[0].length; j++) {

var newNode = document.createElement('div');

newNode.className = 'nene';

newNode.style.top = (i*20) + 'px';

newNode.style.left = (j*20) + 'px';

document.geElemetById('next').appendChild(newNode);

nextDiv.push(newNode);

}

nextDivs.push(nextDiv);

}

}

var refreshGame = function() {

for(var i=0; i<gameData.length; i++){

for(var j=0; j<gameData[0].length; j++){

if(gameData[i][j] == 0){

gameDivs.className = 'none';

}

if(gameData[i][j]==1){

gameDivs[i][i].className = 'done';

}

if(gameData[i][j]==2){

gameDivs[i][j].className = 'current';

}

}

}

}

var refreshNext = function() {

for(var i=0; i<nextData.length; i++){

for(var j=0; j<nextData[0].length; j++){

if(nextData[i][j] == 0){

nextDivs.className = 'none';

} else if(nextData[i][j]==1){

nextDivs[i][j].className = 'done';

} else  if(nextData[i][j]==2){

nextDivs[i][j].className = 'current';

}

}

}

}

initGame();

initNext();

refreshGame();

refreshNext();


正在回答

5 回答

還沒解決

0 回复 有任何疑惑可以回复我~

你这代码写的太随性所欲了啊。。。

0 回复 有任何疑惑可以回复我~

老哥,解决了没

0 回复 有任何疑惑可以回复我~

你这错误量不少啊

0 回复 有任何疑惑可以回复我~

代码不争气,看着难受

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信