Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

NodeIterator

BaselineWidely available

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.

The possible bitmask values are constants from theNodeFilter interface:

ConstantNumerical valueDescription
NodeFilter.SHOW_ALL4294967295 (that is the max value ofunsigned long)Shows all nodes.
NodeFilter.SHOW_ATTRIBUTEDeprecated2Shows attributeAttr nodes. This is meaningful only when creating aNodeIterator with anAttr node as its root; in this case, it means that the attribute node will appear in the first position of the iteration or traversal. Since attributes are never children of other nodes, they do not appear when traversing over the document tree.
NodeFilter.SHOW_CDATA_SECTIONDeprecated8ShowsCDATASection nodes.
NodeFilter.SHOW_COMMENT128ShowsComment nodes.
NodeFilter.SHOW_DOCUMENT256ShowsDocument nodes.
NodeFilter.SHOW_DOCUMENT_FRAGMENT1024ShowsDocumentFragment nodes.
NodeFilter.SHOW_DOCUMENT_TYPE512ShowsDocumentType nodes.
NodeFilter.SHOW_ELEMENT1ShowsElement nodes.
NodeFilter.SHOW_ENTITYDeprecated32Legacy, no longer used.
NodeFilter.SHOW_ENTITY_REFERENCEDeprecated16Legacy, no longer used.
NodeFilter.SHOW_NOTATIONDeprecated2048Legacy, no longer used.
NodeFilter.SHOW_PROCESSING_INSTRUCTION64ShowsProcessingInstruction nodes.
NodeFilter.SHOW_TEXT4ShowsText nodes.
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

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