(^504) ❘ APPENDIX C SELECTING, TRAVERSING, AND FILTERING
bapp03.indd 02/17/2015 Page 504
filter(function(index)) The filter() method may alternatively
accept a function as its fi rst argument, which
works identically to the jQuery $.each()
method. The function is executed for each
item selected.
The function must return a boolean value,
where true indicates that the element should
remain in the result set, and false indicates
that the element should be removed from the
result set.
As with most jQuery callback functions,
this refers to the current element within
the callback function, and the callback func-
tion is provided the argument list:
offset, element.
jQuery
filter(element) Filters the selection based on the JavaScript
node passed in the element argument, ele-
ments that match the node remain in the
selection; elements that do not match the
node are dropped from the selection. One or
more DOM element object references can be
passed in.
jQuery
filter(selection) Filters the selection based on the jQuery
object passed in the selection object (the
result of a jQuery selection) argument. If
elements in the selection match the jQuery
object, they remain in the selection; if not,
those elements are removed from the
selection.
jQuery
find(selector) Makes a selection within the context of
matched elements’ descendants.
jQuery
find(selection) Finds element descendants using an existing
selection object to match element descen-
dants against.
jQuery
find(element) Finds element descendants using an existing
DOM element object to match descendants
against.
jQuery
first() Removes all elements from the selection,
except the fi rst.
jQuery
(continued)
http://www.it-ebooks.info
elliott
(Elliott)
#1