HTML and CSS Reference
In-Depth Information
Figure 13-22
marking incorrect cells
loops th r ough all
of the marked
cells in t he puzzle
if the background
color is white,
changes it to pink
loops throug h all
of the empty cells
in the puzzle
if the ba c kground
color is dark gray,
changes it to red
Next, you'll add an event handler to the Peek button to run the peek() function
when that button is clicked.
2. Scroll up to the init() function and insert the following command as shown in
Figure 13-23:
/* Add an event handler to the Peek! button */
document.getElementById(“peek”).onclick = peek;
Figure 13-23
assigning the peek() function to the onclick event
provides a peek at
the solution when
the button is clicked
3. Save your changes to the file, and then reload hanjie.htm in your Web browser.
4. Go to the 5 Í 5 grid of cells in the upper-right corner of the first puzzle, darken the
first three columns of that grid, and then mark the last two columns as empty, as
shown in the left grid in Figure 13-24.
5. Click the Peek! button and then verify that your browser highlights the incorrect
cells, as shown in the right grid in Figure 13-24.
Search WWH ::

Custom Search