Mozilla.com

  1. MDC
  2. Main Page
  3. DOM
  4. treeWalker.filter
Table of contents
  1. 1. Summary
  2. 2. Syntax
  3. 3. Example
  4. 4. Notes
Table of contents
  1. 1. Summary
  2. 2. Syntax
  3. 3. Example
  4. 4. Notes

« Gecko DOM Reference

Summary

Returns an object with a method acceptNode(node).

Syntax

nodeFilter = treeWalker.filter;

Example

var treeWalker = document.createTreeWalker(
    document.body,
    NodeFilter.SHOW_ELEMENT,
    { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
    false
);
nodeFilter = treeWalker.filter; // document.body in this case

Notes

When creating the TreeWalker, the filter object is passed in as the third parameter, and the object method acceptNode(node) is called on every single node to determine whether or not to accept it. This function should return the constant NodeFilter.FILTER_ACCEPT for cases when the node should be accepted and NodeFilter.FILTER_REJECT for cases when the node should be rejected.

Page last modified 02:46, 27 Dec 2006 by Warhammerkid?

Files (0)