<div id="root"> <div id="child1"></div> <div id="child2"></div> </div> 

I hide the child elements of $('#child1').hide() . It is necessary to determine whether the parent element has visible children: $('#root').child('div:hidden').length . This is understandable, but if you hide the parent $('#root').hide() , then the children are hidden even if they are made .show() .

Is there another way to find out the number of hidden-visible items from the parent, besides iterating through the loop and checking $('#child1').css('display') ?

  • And what is the method that does not fit? - Dmitry Nail
  • What is the brute force css not suitable? I like to do less code where it is possible. - toxxxa

1 answer 1

To get the number of visible, in this case

 $('#root > *:not([style])').length