Check for visible items inside a div

Posted on

Question :

How to check if there is any visible element or vice versa within a <div> ?

I can get around with jQuery and tried using el.is(':visible') but I could not because I need to check if everyone inside <div> is hidden.

    

Answer :

With your friend’s comment @marcelobonifazio

The author was able to use:

var divFilho = divPai.find('ul:visible').length;

if(divFilho === 0){
    divPai.hide().addClass('hidden');
}

    

Leave a Reply

Your email address will not be published. Required fields are marked *