Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. NodeIterator

NodeIterator

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

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

ANodeIterator can be created using theDocument.createNodeIterator() method, as follows:

js
const nodeIterator = document.createNodeIterator(root, whatToShow, filter);

Instance properties

This interface doesn't inherit any property.

NodeIterator.rootRead only

Returns aNode representing the root node, as specified when theNodeIterator was created.

NodeIterator.whatToShowRead only

Returns anunsigned long bitmask that describes the types ofNodeto be matched. Non-matching nodes are skipped, but relevant child nodes may be included.

NodeIterator.filterRead only

Returns aNodeFilter used to select the relevant nodes.

NodeIterator.referenceNodeRead only

Returns theNode to which the iterator is anchored.

NodeIterator.pointerBeforeReferenceNodeRead only

Returns a boolean indicating whether or not theNodeIterator is anchoredbefore theNodeIterator.referenceNode. Iffalse, it indicates that the iterator is anchoredafter the reference node.

Instance methods

This interface doesn't inherit any method.

NodeIterator.detach()Deprecated

This is a legacy method, and no longer has any effect. Previously it served to mark aNodeIterator as disposed, so it could be reclaimed by garbage collection.

NodeIterator.previousNode()

Returns the previousNode in the document, ornull if there are none.

NodeIterator.nextNode()

Returns the nextNode in the document, ornull if there are none.

Specifications

Specification
DOM
# interface-nodeiterator

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp