#grid{
width:316px;
height: 316px;
background-color: #00BFFF;
}
.cell {
width: 60px;
height: 60px;
服务器托管网 border: 1px solid black;
float: left;
}
.red {
background-color: red;
}
.black {
bac服务器托管网kground-color: black;
}
var grid = [];
var size = 5;
var gridElement = document.getElementById('grid');
for (var i = 0; i < size; i++) {
var row = [];
for (var j = 0; j < size; j++) {
var cell = document.createElement('div');
cell.className = 'cell red';
cell.onclick = (function(i, j) {
return function() {
toggleColor(i, j);
}
})(i, j);
gridElement.appendChild(cell);
row.push(cell);
}
grid.push(row);
}
grid[2][2].className = 'cell black';
function toggleColor(i, j) {
var directions = [[-1, 0], [1, 0], [0, -1], [0, 1]];
for (var k = 0; k = 0 && ni = 0 && nj < size) {
var cell = grid[ni][nj];
cell.className = cell.className === 'cell red' ? 'cell black' : 'cell red';
}
}
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
相关推荐: 【Electron+Vue】Error: error:0308010C:digital envelope routines::unsupported
问题描述 使用 electron-builder 构建 vue 项目,运行 npm run electron:build ,构建过程报错。 / Bundling main process… ERROR Failed to compile with 1 er…