Reputation: 1
$('#navs li').find('.activenav').filter('.activenav').removeClass('activenav');
or
$('#navs li').filter('.activenav').find('.activenav').removeClass('activenav');
Upvotes: 0
Views: 125
Reputation: 151
.filter
will find entries in the returned array that also match the filter query, and .find
queries each of those to find children that match the query you entered.
With the markup:
<div class="cheese">
<div class="cheddar"></div>
<div class="wensleydale"></div>
<div class="brie">
<div class="camembert"></div>
</div>
</div>
This:
$('.cheese div').filter('.brie');
Would return the brie div, but this:
$('.cheese div').filter('.camembert');
Would return nothing, when this:
$('.cheese div').find('.camembert');
Would search deeper, and retrieve the camembert div.
Which is a shame, because Camembert is disgusting.
Upvotes: 2
Reputation: 2156
find
will search in the decedents for matching elements
filter
will keep only the matching elements from a set of elements.
Upvotes: 0
Reputation: 2903
According to this link... http://www.mkyong.com/jquery/difference-between-filter-and-find-in-jquery/
Both filter() and find() methods are very similar, except the former is applies to all the elements, while latter searches child elements only.
Upvotes: 0
Reputation: 20415
Description: Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
Description: Reduce the set of matched elements to those that match the selector or pass the function's test.
Upvotes: 3