Reputation: 2243
How can I count the number of items in div that are hidden using Jquery?
Upvotes: 7
Views: 17258
Reputation: 5899
I think that
$("#someElement > *").filter(":hidden").size();
will work.
Updated: Added the '*'. Note that this will select the immediate children of #someElement
.
Upvotes: 11
Reputation: 155792
Direct children of someElement that are hidden:
$('#someElement > :hidden').length;
Any descendants of someElement that are hidden:
$('#someElement :hidden').length;
If you already have a jQuery object you can use it as the context:
var ele = $('#someElement');
$(':hidden', ele).length;
Upvotes: 19