Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

nextNode method

Returns the next node in the NodeIterator or TreeWalker list and updates currentNode.

Document Object Model (DOM) Level 2 Traversal and Range Specification, Section 1.2Internet Explorer 9





oNode [out, retval]

Type: Node

Object containing the next node in the list.

Return value

Type: Node

Object containing the next node in the list.

Standards information


This example shows how to create a NodeIterator and move forward through the list of nodes.


<!DOCTYPE html>
<title>NextNode example</title>
  <script type="text/javascript">
    function LoseMondays(){
	  var ni = document.createNodeIterator(document.body, NodeFilter.SHOW_TEXT, null, false);
      var txt = ni.nextNode();      //go to first node of our NodeIterator
      while (txt)                   //while text
          if (txt.wholeText.match('Monday') || txt.parentNode.getAttribute('id') == 'Monday')
            txt.parentNode.removeChild(txt);        //remove monday's activity
          txt=ni.nextNode();                        //go to next node
    function refresh()                 
        window.location.reload( false );           //reload our page
    <p><strong>Harry's weekly diary</strong></p>
    <p>Monday Joe bought a turkey.</p>
    <p>Tuesday Bill bought a pound of ham.</p>
    <div>Chuck called in sick Monday.</div>
    <p id="Monday">CALL supplier today</p>
    <p>Wednesday's delivery was delayed.</p>
    <input type="button" name="reset" value="refresh" onclick="refresh()"/>
    <input type="button" name="cutmonday" value="Lose Mondays" onclick="LoseMondays()"/>

See also




© 2015 Microsoft