Saturday, October 25, 2025
HomeLanguagesJavascriptHTML DOM NodeIterator whatToShow Property

HTML DOM NodeIterator whatToShow Property

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;">
        neveropen
    </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
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS