Reputation: 14165
Why this code don't hide selected elements:
$(selector).filter(function() {
return true;
}).hide();
Although this code hides:
$(selector).hide();
How to hide elements using filter in jquery
?
In this example I used simple filter, that always true - only for example.
Upvotes: 0
Views: 74
Reputation: 10378
$(selector).filter(function() {
return this; //here pass this to return filter object
}).hide();
Upvotes: 2
Reputation: 74738
instead of returning true return this
so change this:
return true;
to this:
return this;
Upvotes: 2