tags:

views:

43

answers:

3

Hello,

I have recently jumped into the world of JQuery. I saw the methods find() and filter() but can not figure out the difference between the two.

What exactly is the difference between the two?

+2  A: 

find() returns children of the match elements for the given selector, filter() looks at the matched elements and returns the ones that also match the given selector.

Dean Harding
+4  A: 

filter reduces the set of already matched elements, while find gets descendants of the matched element.

Darin Dimitrov
@Darin: That was so easy and clear explanation, thanks :)
Sarfraz
+3  A: 

find()

find() returns the descendants of the selected elements that match the selector.

From the doc:

Description: Get the descendants of each element in the current set of matched elements, filtered by a selector.

filter()

filter() filters the elements based on the selector or the provided function.

From the doc:

Description: Reduce the set of matched elements to those that match the selector or pass the function's test.

Obalix