Check for visible items within a div

Asked

Viewed 335 times

4

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

I can manage with jQuery and tried using el.is(':visible') but I couldn’t because I need to check if everyone inside the <div> is hidden.

  • 1

    This might help: http://answall.com/questions/31934/contar-inputs-vis%C3%Adveis-e-ativos-no-meu-formul%C3%A1rio

  • 1

    Thiago, this is not a forum but a Q&A I recommend you take the tour to see how the site works: http://answall.com/tour - Do not post the answer inside the question or in comments. You can answer your own question by using the "answer" button - see the tour. See that I posted an answer with what you added in the question, if you want to copy and answer again and I delete my answer.

  • 1

    @Thiagodiniz please formulate an answer if you want, so I will delete mine that I added only so the question does not get answer in her body.

1 answer

3


With the comment of the friend @marcelobonifazio

The author managed using:

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.