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

Syntax

object.nextNode(oNode)

Parameters

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

Remarks

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

Examples


<!DOCTYPE html>
<html>
<head>
<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
      }
  </script>
</head>
<body>
    <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()"/>
</body>
</html>

See also

NodeIterator
TreeWalker

 

 

Show:
© 2014 Microsoft