Name

TreeWalker.nextNode( ) — return the next node that is not filtered out

Availability

DOM Level 2 Traversal

Synopsis

Node nextNode(  );

Returns

The node that follows the current node in the document source and is not filtered out, or null if there is none.

Description

This method sets currentNode to the next node (in document source order) that is not filtered out and returns that node. If there is no such node, or if the search for the next node takes the TreeWalker outside of the root subtree, currentNode remains unchanged and the method returns null.

Note that this method “flattens” the document tree structure and returns nodes in the order in which they appear in the document source. Calling nextNode( ) may cause the current node to move down, sideways, or up the document tree. This type of flattening traversal can also be performed with NodeIterator.nextNode( ).

Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.