AvailabilityDOM Level 2 Traversal SynopsisNode nextNode( ) throws DOMException; ReturnsThe next node in the sequence of nodes represented by this NodeIterator, or null if the last node has already been returned. ThrowsIf this method is called after a call to detach( ), it throws a DOMException with a code of INVALID_STATE_ERR. DescriptionThis method iterates forward through the sequence of nodes represented by this NodeIterator. If this is the first time it is called for a NodeIterator, it returns the first node in the sequence. Otherwise, it returns the node that follows the one that was previously returned. Example// Create a NodeIterator to represent all elements in the document body var ni = document.createNodeIterator(document.body, NodeFilter.SHOW_ELEMENT, null, false); // Loop forward through all nodes in the iterator for(var e = ni.nextNode( ); e != null; e = ni.nextNode( )) { // Do something with element e } |