HTML and CSS Reference
In-Depth Information
To append the nested list:
◗
1.
Return to the
toc.js
file in your text editor.
◗
2.
Within the second
if
condition, insert the following code, as shown in Figure 14-28:
var nestedList = document.createElement(“ol”);
nestedList.appendChild(listItem);
/* Append nested list to last item in the current list */
TOCList.lastChild.appendChild(nestedList);
/* Change the current list to the nested list */
TOCList = nestedList;
Figure 14-28
creating a nested list
◗
3.
Save your changes to the file, and then reload
usconst.htm
in your Web browser.
Figure 14-29 shows part of the table of contents.
Figure 14-29
viewing the nested list
Trouble?
If your TOC does not appear like the one shown in Figure 14-29, check
your code against the code shown in Figure 14-28 for errors.