Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

288
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!