Clicking the button will alert the number of items with the class of "selected" applied.
To illustrate the use of filter, we'll create a few HTML lists. When the button is clicked, we filter the collection of
LIelements, 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
Note: You are viewing this example in debug mode with logging enabled. This can significantly slow performance.
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.