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

291
Visualizações
How to Deal with Hidden Element without Removing it - updating DOM length when Element hidden

I have a list of brand names looking like this:

enter image description here

each element has a border-bottom style and I used the below code to remove border-bottom style when there are less than 5 elements and it works perfectly until you make a search and some of these elements are hidden. The problem is because even display = 'none'; doesn't remove the elements from DOM. According to DOM, its length is the same so even there is one element and others are hidden border style is there. (img below code)

&:nth-child(5n+1):nth-last-child(-n+5), &:nth-child(5n+1):nth-last-child(-n+5) ~ .brands__list-item {
  @apply lg:border-b-0;
}

enter image description here

Removing elements from DOM instead of hiding works, but I need these elements later so I can't remove them. I want elements to have a border If a row has more than 5 elements. How can I tackle this issue of hidden elements? Open to any suggestions.

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

0

I don't know any exact property to use it, but here are some tricks you can use.
Just put the hidden element in a class and style it with display:none.

After adding that class, just use:

length2=DOM.classList.contains('classWithHiddenProp');
totalLength_of_DOM = totalLength - length2;
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