HTML and CSS Reference
In-Depth Information
Figure 14-44
inserting the plus/minus box in the node tree
TOCList .lastChild.lastChild
plus/minus box
Based on the node tree, the plus/minus box should be placed as the first child of
the currently last list item in the TOC. You can insert a node into this location using
the insertBefore() method. Recall that the general syntax of the insertBefore()
method is
node .insertBefore( new , child )
where node is the parent node, new is a new node to be added as a child of the parent,
and child is the child node that the new node should be inserted in front of. Thus, to
insert the plus/minus box, you'll apply the following command:
TOCList.lastChild.insertBefore(plusMinusBox, TOCList.lastChild.
Compare this command to the node diagram in Figure 14-44 to see how the use of
familial references makes it easier to specify exact locations within the structure of the
You'll add code now to place the plus/minus box.
To insert the plus/minus box:
1. Directly below the code you inserted in the last set of steps, insert the following
statements as shown in Figure 14-45:
/* Insert the plus-minus box directly before
the last item in the current list */
TOCList.lastChild.insertBefore(plusMinusBox, TOCList.lastChild.
Figure 14-45
inserting the plus/minus box
Search WWH ::

Custom Search