Skip to content
Related Articles

Related Articles

Improve Article
HTML DOM TreeWalker filter Property
  • Last Updated : 28 Jul, 2020

The TreeWalker filter property returns a Filter node that is a filtering object associated with the created TreeWalker. It is a read-only property.

When creating the TreeWalker, the filter node or object is passed as the third parameter which is retrieved using this property.


nodeFilter = treeWalker.filter;

Return Value: This property returns a node filter of the TreeWalker.

Example: In this example, we will get the node filter of the TreeWalker using this property.


<!doctype html>
    <p>Click Here to get the filter node</p>
    <button onclick="get()">Click</button>
        var treeWalker = document.createTreeWalker
            (document.head, NodeFilter.SHOW_ELEMENT,
                    acceptNode: function (node) 
                    { return NodeFilter.FILTER_ACCEPT; }
        function get() {
            node = treeWalker.filter;


  • Before Clicking the Button:

  • After Clicking the Button: In console filter, node can be seen.

Supported Browsers: 

  • Google Chrome
  • Edge
  • Firefox
  • Safari
  • Opera
  • Internet Explorer
My Personal Notes arrow_drop_up
Recommended Articles
Page :