Join us online - 19th of November
Save your spot
For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.

Interface NodeIterator

The NodeIterator interface represents an iterator to traverse nodes of a DOM subtree in document order.

MDN Reference

interface NodeIterator {
    filter: NodeFilter | null;
    pointerBeforeReferenceNode: boolean;
    referenceNode: Node;
    root: Node;
    whatToShow: number;
    detach(): void;
    nextNode(): Node | null;
    previousNode(): Node | null;
}
Index
filter: NodeFilter | null

The NodeIterator.filter read-only property returns a NodeFilter object, that is an object which implements an acceptNode(node) method, used to screen nodes.

MDN Reference

pointerBeforeReferenceNode: boolean

The NodeIterator.pointerBeforeReferenceNode read-only property returns a boolean flag that indicates whether the NodeFilter is anchored before (if this value is true) or after (if this value is false) the anchor node indicated by the NodeIterator.referenceNode property.

MDN Reference

referenceNode: Node

The NodeIterator.referenceNode read-only property returns the Node to which the iterator is anchored; as new nodes are inserted, the iterator remains anchored to the reference node as specified by this property.

MDN Reference

root: Node

The NodeIterator.root read-only property represents the Node that is the root of what the NodeIterator traverses.

MDN Reference

whatToShow: number

The NodeIterator.whatToShow read-only property represents an unsigned integer representing a bitmask signifying what types of nodes should be returned by the NodeIterator.

MDN Reference

  • The NodeIterator.detach() method is a no-op, kept for backward compatibility only.

    Returns void

    MDN Reference

  • The NodeIterator.nextNode() method 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.

    MDN Reference

    Returns Node | null

  • The NodeIterator.previousNode() method returns the previous node in the set represented by the NodeIterator and moves the position of the iterator backwards within the set.

    MDN Reference

    Returns Node | null

Was this helpful?