Open In App

HTML DOM NodeIterator whatToShow Property

Improve
Improve
Like Article
Like
Save
Share
Report

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

Syntax:

var nodeTypes = nodeIterator.whatToShow;

Return Value: It returns an unsigned integer representing a bitmask.

Possible return values:

Constant Return Value Constant Description
NodeFilter.SHOW_ALL

1

Shows all nodes.
NodeFilter.SHOW_COMMENT

128

Shows Comment nodes.
NodeFilter.SHOW_DOCUMENT

256

Shows Document nodes.
NodeFilter.SHOW_DOCUMENT_FRAGMENT

1024

Shows DocumentFragment nodes.
NodeFilter.SHOW_DOCUMENT_TYPE

512

Shows DocumentType nodes.
NodeFilter.SHOW_ELEMENT

1

Shows Element nodes.
NodeFilter.SHOW_PROCESSING_INSTRUCTION

64

Shows ProcessingInstruction nodes.
NodeFilter.SHOW_TEXT

4

Shows Text nodes.

Example: In this example, we will create a node iterator and will get that unsigned integer using this property.

HTML




<!DOCTYPE HTML>
<html>
  
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
  
    <p>
        HTML | DOM NodeIterator whatToShow property
    </p>
  
  
    <button onclick="Geeks()">
        Click Here
    </button>
  
    <p id="a"></p>
  
    <script>
        var a = document.getElementById("a");
        function Geeks() {
            const nodeIterator = 
            document.createNodeIterator(
                document.body,
                NodeFilter.SHOW_ELEMENT,
                { acceptNode: function (node) { 
                    return NodeFilter.FILTER_ACCEPT; } },
                false
            );
            a.innerHTML = "whattoshow bitmask is : "
                    + nodeIterator.whatToShow;
  
        }
    </script>
</body>
  
</html>


Output:

  • Before Clicking the Button:

  • After Clicking the Button: Here for NodeFilter.SHOW_ELEMENT we got bitmask unsigned integer as 1.

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Safari
  • Opera
  • Internet Explorer


Last Updated : 27 Jul, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads