Skip to content
Related Articles

Related Articles

Improve Article
HTML DOM NodeIterator filter property
  • Last Updated : 29 Jul, 2020

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

While creating a NodeIterator, the filter object is passed as the third parameter in createNodeIterator() method, and the object method acceptNode(node) is called on every single node to determine whether to accept it. This is a read-only property.


nodeFilter = nodeIterator.filter;

Return Value: returns a NodeFilter object.

Example: In this example, we will create a node iterator and will get the NodeFilter object using this property.

    <meta charset="UTF-8">
    <title>HTML | DOM NodeIterator filter property</title>
<body style="text-align:center;">
    <h1 style="color:green;">  
HTML | DOM NodeIterator filter property
    <button onclick = "Geeks()">
    Click Here
    <p id="a"></p>
        var a = document.getElementById("a");
        function Geeks(){
           const nodeIterator = document.createNodeIterator(
            { acceptNode: function(node) {
 return NodeFilter.FILTER_ACCEPT; } },


Before Clicking Button:

After Clicking Button: In the console, the NodeFilter object can be seen.

Supported Browsers:

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :