HTML and CSS Reference
In-Depth Information
Figure 14-27
appending a nested list
<li>item 1</li>
<li>item 2
<li>item 3</li>
HTML fragment
" item 1 "
" item 2 "
" item 3 "
corresponding node tree
To do this in JavaScript, you'll create a new ordered list and then append the list item
to it using the following commands:
var nestedList = document.createElement(“ol”);
The nested list is then appended as a child of the previous—and currently last—entry in
the current list, which can be done using the following command:
Finally, you'll need to set the nested list as the new table of contents so that the text of
subsequent headings is added to it. You'll run the following command to change the
reference of the TOCList variable:
TOCList = nestedList;
You'll add these commands to the second if condition in the createList() function now.
Search WWH ::

Custom Search