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

145
Visualizações
Hide all instances of LI except first in UL jQuery

I have 100 instances of this class on my in my HTML status-list. I would like to loop over all the UL elements with this class and hide all nested list items except the first one. How can I achieve this using jQuery?

I have tried the following but receive this error:

[0].siblings is not a function

$('.status-list').each(function(i, obj) {
    ($(this)[0]).siblings().hide();
});

I realize this code above would hide all objects under the ul, however I am struggling to just be able to hide sibling elements at all.

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

0

You should use css selectors

$('.status-list').each(function() {
  $(this).children("li:not(:first-child)").hide();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul class="status-list">
  <li>list 11</li>
  <li>list 12</li>
  <li>list 13</li>
  <li>list 14</li>
  <li>list 15</li>
  <li>list 16</li>
</ul>

<ul class="status-list">
  <li>list 21</li>
  <li>list 22</li>
  <li>list 23</li>
  <li>list 24</li>
  <li>list 25</li>
  <li>list 26</li>
</ul>

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