NodeIterator.nextNode

  • Revision slug: DOM/NodeIterator.nextNode
  • Revision title: NodeIterator.nextNode
  • Revision id: 136558
  • Created:
  • Creator: Jürgen Jeka
  • Is current revision? No
  • Comment 4 words added, 4 words removed

Revision Content

{{ DomRef() }}

{{ gecko_minversion_header("1.9.1") }}

Summary

Returns the next node in the set represented by the NodeIterator and advances the position of the iterator within the set.  The first call to nextNode() returns the first node in the set.

This method returns null when there are no nodes left in the set.

Throws the INVALID_STATE_ERR DOMException if this method is called after the detach() method.

Syntax

node = nodeIterator.nextNode();

Example

var nodeIterator = document.createNodeIterator(
    document.body,
    NodeFilter.SHOW_ELEMENT,
    { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
    false
);
currentNode = nodeIterator.nextNode(); // returns the next node

 

Revision Source

<p>{{ DomRef() }}</p>
<p>{{ gecko_minversion_header("1.9.1") }}</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>Returns the next node in the set represented by the <a class="internal" href="/En/DOM/NodeIterator" title="En/DOM/NodeIterator"><code>NodeIterator</code></a> and advances the position of the iterator within the set.  The first call to <code>nextNode()</code> returns the first node in the set.</p>
<p>This method returns <code>null</code> when there are no nodes left in the set.</p>
<p>Throws the <code>INVALID_STATE_ERR</code> <code>DOMException</code> if this method is called after the <a class="internal" href="/En/DOM/NodeIterator.detach" title="En/DOM/NodeIterator.detach"><code>detach()</code></a> method.</p>
<h3 id="Syntax" name="Syntax">Syntax</h3>
<pre class="eval">node = nodeIterator.nextNode();
</pre>
<h3 id="Example" name="Example">Example</h3>
<pre class="eval">var nodeIterator = document.createNodeIterator(
    document.body,
    NodeFilter.SHOW_ELEMENT,
    { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
    false
);
currentNode = nodeIterator.nextNode(); // returns the next node
</pre>
<p> </p>
Revert to this revision