对于井字游戏,我使用以下代码将图像源更改为“x”或“o”:
var player = 1;
function changePicture(picture){
if(player === 1){
document.getElementById(picture).src = "images/o.png";
player = 2;
}
else if(player === 2){
document.getElementById(picture).src = "images/x.png";
player = 1;
}
}
但是,如果之后单击它们,我希望保持 x 和 o 不变。