You are here: Reference > JavaScript > client-side > xml handling > properties > filter (NodeIterator, TreeWalker)
filter property (NodeIterator, TreeWalker)
9 | ||||
Returns the filtering that function belongs to the NodeIterator or TreeWalker object.
Note: The TreeWalker and NodeIterator objects and their filter properties are supported in Internet Explorer from version 9.
You can set this property by the third parameter of the createNodeIterator or createTreeWalker method.
The filter property cannot be used in Firefox for security reasons. See the example for details.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read-only.
Possible values:
String that specifies the name of the function to filter the nodes.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the filter property:
|
||||
<head> <script type="text/javascript"> function ButtonChecker (node) { if (node.tagName.toLowerCase () == 'button') { return NodeFilter.FILTER_ACCEPT; } return NodeFilter.FILTER_SKIP; } function TestFilter () { if (document.createTreeWalker) { var walker = document.createTreeWalker (document, NodeFilter.SHOW_ELEMENT, ButtonChecker, false); try { var filterFunction = walker.filter; alert ("The TreeWalker is filtered by this method:\n\n" + filterFunction); } catch (e) { // Firefox alert (e); } } else { alert ("Your browser does not support the createTreeWalker method!"); } } </script> </head> <body> <button onclick="TestFilter ()">Test filter property</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments