Web hosting companies - 314Part IIIDocument Objects ReferenceListing 15-31(continued) if (document.getElementById( myOL ) &&

314Part IIIDocument Objects ReferenceListing 15-31(continued) if (document.getElementById( myOL ) && oldNode) { var innards = document.getElementById( myOL ).children; while (innards.length > 0) { oldNode.insertBefore(innards[0]); } document.getElementById( myOL ).replaceNode(oldNode); } } // swap first and last nodesfunction swap() { if (document.getElementById( myUL )) { document.getElementById( myUL ).firstChild.swapNode( document.getElementById( myUL ).lastChild); } if (document.getElementById( myOL )) { document.getElementById( myOL ).firstChild.swapNode( document.getElementById( myOL ).lastChild); } } // remove last nodefunction remove() { if (document.getElementById( myUL )) { document.getElementById( myUL ).lastChild.removeNode(true); } if (document.getElementById( myOL )) { document.getElementById( myOL ).lastChild.removeNode(true); } }

Node Methods


Here is a list of items:
  • First Item
  • Second Item
  • Third Item
  • Fourth Item
        

You can accomplish the same functionality shown in Listing 15-31 in a cross-browser fashionusing the W3C DOM. In place of the removeNode()and replaceNode()methods, useremoveChild()and replaceChild()methods to shift the point of view (and object references) elementObject.replaceNode()

Leave a Reply