Chapter 3
Interact with the Grid
Section 3
Add a Click Handler
Now, it's time to add a click handler to our code so that we can add live cells to the grid. Here's what we're after: we want you to be able to click on a dead cell to change it to live, and then click on it again to change it back to dead (in case you change your mind). Remember, to do that, when a cell is clicked, our handler is going to make use of the two CSS classes, live and dead. So, the click handler will be responsible for checking the state the cell, that is, live or dead, and then setting the cell to the opposite state (dead or live).