Do you feel we're on a roll? I hope so! Let's move on to creating the cell_clicked function. You must first ask yourself,
"What happens when the player clicks a cell?".


I hope your answer was ... we want to put the current counter in the empty cell.
For the moment, let's always put a red counter in the clicked cell.
You'll need a new JavaScript function before you can create this function by yourself.
It's the setAttribute function.
Store your function in a separate file called cell_clicked.js.


function cell_clicked(image) {
  image.src='counters/1.png';
  image.setAttribute('cn','1');
}

Back to index.html. Add the necessary line to make this function available and it all should work!


On the next page I'll show you what I've ended up with so far.