HTML and CSS Reference
In-Depth Information
You'll add the command to insert the list item to the first condition in the createList()
function now.
To add the command for the first condition:
1. Add the following command to the first if condition, as shown in Figure 14-26:
TOCList.appendChild(listItem);
Figure 14-26
appending a list item to the current tOc level
2. Save your changes to the file.
3. Reload usconst.htm in your Web browser, and then verify that the TOC is still
displayed and no errors are reported by your browser.
Trouble? You might notice that a few headings from the source document do
not appear in the TOC. This will be corrected as you add more code to the
createList() function.
The next if condition involves the situation where the new heading is at a lower level
than the previous heading. In those cases, you want to insert the list item within a new
nested list. Figure 14-27 shows the HTML fragment and node tree of the resulting new
content in the table of contents.
 
Search WWH ::




Custom Search