i want that when i clicked the block, ‘O’ appears on the other block. But it appears only one time. I know that not solution, but i want understand how it works
document.getElementById('game').onclick = function(event) {
var allBlock = document.getElementsByClassName('block');
if (event.target.className == 'block') {
event.target.innerHTML = 'X';
}
for (var i = 0; i < 8; i++) {
if (allBlock[i].innerHTML !== 'X') {
allBlock[i].innerHTML = 'O';
break;
}
}
checkWinner();
};