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

146
Views
How to document.getElementById with more than one ID?

how can I add more than one ID in the following code?

function myFunction() {
    var popup = document.getElementById("myPopup");
    popup.classList.toggle("show");
}

I have tried tried it with querySelectorAll but then no popup shows?

 function myFunction() {
    var popup = document.querySelectorAll("#myPopup, #myPopup2");
    popup.classList.toggle("show");
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

querySelectorAll returns a NodeList which must be traversed through to access each element:

document
  .querySelectorAll('#myPopup, #myPopup2')
  .forEach(function(element){
    element.classList.toggle("show");
  })
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!