我想更改多维数组的值,但这段代码一直告诉我“无法设置未定义的属性'5'(我猜是数组的长度)”
obj.figures = new Array(
new Array(6,5,5,5,6,5,5),
new Array(5,0,0,0,5,0,0),
new Array(5,5,5,5,5,5,5),
new Array(0,1,1,1,0,2,2),
new Array(0,1,0,1,0,2,0)
);
function change() {
for(var y = 0; y<obj.figures.length; y++) {
for(var x = 0; x<obj.figures[y].length; x++) {
$(y+","+x).addEventListener("click", function() {
console.log(this.id);
obj.figures[y][x] = 5;
}, false);
}
}
}