NodeIterator: nextNode() method - Web APIs | MDN

Syntax

Parameters

None.

Return value

A Node representing the node after the current node in the set represented by this NodeIterator, or null if the current node is the last node in the set.

Examples

js

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

Specifications

Specification
DOM
# dom-nodeiterator-nextnode

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.