9.19.2012

jQuery.find() vs jQuery.filter()

Difference between find() and filter() in jQuery
S.No
jQuery.find()
jQuery.filter()
1 What it does ?
Searches through all the child elements in the matched set.
What it does ?
Searches through all elements in the matched set
2 Description:
Get the descendants of each element in the current set of matched elements, filtered by a selector.
Description:
Reduce the set of matched elements to those that match the selector or pass the function's test.
3 Syntax:
.find( selector )
selector: A string containing a selector expression to match elements against.

.find( jQuery object )
jQuery object: A jQuery object to match elements against.

.find( element )
element: An element to match elements against.

Syntax:
.filter( selector )
selector: A string containing a selector expression to match the current set of elements against.

.filter( function(index) )
function(index): A function used as a test for each element in the set. this is the current DOM element.

.filter( element )
element: An element to match the current set of elements against.

.filter( jQuery object )
jQuery object: An existing jQuery object to match the current set of elements against.


Reference:


No comments:

Post a Comment