Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

287
Visualizações
How to check for first element in JavaScript that has no style of display none?

I have got a list of li elements as I filter data I exclude the unneeded elements by setting the display to none. I would like to check for the first element that has no style of display set to it how can I do this: Example of element with display none:

<li style="display: none;"><a href="#" data-key="81" data-value="Example 1">Data</a></li> 

Example of element that has no attribute of display none:

<li style=""><a href="#" data-key="1" data-value="Example2">Example2</a></li>

My JavaScript Code:

var liValue = $("#UlId").find('li:not([style*="display: none"])').val();

How can I get the first li that is visible.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

If you only want first visible value find and eq(0) is your friend.

var liValue = $("#UlId").find('li:not([style*="display: none"])').eq(0).find('a').text();
console.log(liValue);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul id="UlId">
  <li style="display: none;"><a href="#" data-key="81" data-value="Example 1">Data</a></li>
  <li style=""><a href="#" data-key="1" data-value="Example2">Example2</a></li>
  <li style=""><a href="#" data-key="2" data-value="Example3">Example3</a></li>
</ul>

about 4 years ago · Juan Pablo Isaza Relatório

0

you can use this

$('li:visible:first')
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda