Reputation: 6325
<ul id ='caseStudies'>
<li class="humor crime fantasy hidden"> A </li>
<li class="crime"> B </li>
<li class="humor crime hidden"> C </li>
<li class="humor crime"> D </li>
<li class="humor crime fantasy action hidden"> E </li>
<li class="fantasy action"> F </li>
<li class="humor fantasy"> G </li>
<li class="crime action hidden"> H </li>
</ul>
$('ul#caseStudies li.hidden').each(function() {
}//this will get all the LI in the UL that has got class 'hidden'
But how do i get all the LI in the UL that hasn got a class 'hidden'?
Upvotes: 0
Views: 720
Reputation: 187110
Use :not selector
$('#caseStudies li:not(".hidden")')
Edit
To get the count also
var notHiddenElems = $('#caseStudies li:not(".hidden")');.
var notHiddenElemsLength = notHiddenElems.length;
notHiddenElems.each(function(){
// you can use notHiddenElemsLength here
});
See length
Upvotes: 3
Reputation: 344803
try the :not()
selector
$('ul#caseStudies li:not(.hidden)').each(function() {
}
Upvotes: 4