Clicking the button will filter the collection of LIs, leaving only those that have the class of "selected" applied.
filter, part of the YUI Selector Utility, makes it easy to filter a set of nodes based on a CSS3 Selector.
To illustrate the use of filter, we'll create a few HTML lists. When the button is clicked, we filter the collection of LI
elements, so that only those that have the class selected
applied are left in the array.
Add some markup for the lists and a button to trigger the demo:
Now we will define the function that filters the nodes when the button is clicked, and assign it as a click handler.
This is a basic example of how to use the Selector.filter
method.
Note: Logging and debugging is currently turned off for this example.
Copyright © 2007 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings