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?
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?
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.
filter reduces the set of already matched elements, while find gets descendants of the matched element.
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.