HTML and CSS Reference
In-Depth Information
2. Save your changes to the file, and then reload usconst.htm in your Web browser.
Plus-minus boxes should appear before the nested list titles in the table of con-
tents. See Figure 14-46.
Figure 14-46
plus-minus boxes in the table of contents
Adding an Event Handler to the Plus/Minus Boxes
Every time a user clicks the plus/minus box, the nested list should be alternately
displayed and hidden, and the character in the box should alternate between the
- symbol and the + symbol. You'll place the commands to perform these actions in the
expandCollapse() function, and you'll run the function in response to an onclick event.
You'll create the event handler now.
To create the event handler:
1. Directly after the command to insert the plus/minus box, insert the following
statements as shown in Figure 14-47:
/* Expand and collapse the TOC and the document when
the plus/minus box is clicked */
plusMinusBox.onclick = expandCollapse;
Figure 14-47
applying an event handler to the plus/minus box
runs the
expandCollapse()
function when
the b o x is clicked
2. Save your changes to the file.
Search WWH ::




Custom Search