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

252
Views
Is there a way to Hide/unhide all child elements of a DOM node in JavaScript?

Say I have the following HTML and I want to hide all the children of the 'overlay' div dynamically

<div id="overlay" class="foo">
    <h2 class="title">title</h2>
    <h1 id="bar">sub-title</h1>
    <button id="reset">reset</button>
</div>

is there a better way to mass hide/unhide these elements than calling .className = 'hide' on them individually?

*note that I want to retrieve those later so looping over them with .remove() or setting div innerHTML to an empty string is not an option

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In your css you can create this:

#overlay.hidden-content > * {
 visibility: hidden
}

And add hidden-content to your div with overlay id to hide all the child elements.

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!