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

257
Views
Click two elements at the same time by clicking one button with javascript

Is it possible to click one button and simultaneously click another element. Like I click a button to show an image and simultaneously let something else appear which would also appear when clicking on it

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

0

It's totally possible. You have to get the click event of the element, and you can do whatever you want.

Example:

  <button id="button">I am a button</button>
  <div id="anotherElement"></div>
  <script>
    const button = document.getElementById('button');
    const anotherElement = document.getElementById('anotherElement');
    button.addEventListener('click', () => {
      // do whatever you want here
      anotherElement.click();
    });
  </script>
about 4 years ago · Juan Pablo Isaza Report

0

As our friend Said says, is possible, just I think if would be better if you name classes instead of ID because is a better practice

   <button class="button">Do something here</button>
   <button class="button">And here</button>
   <script>
     const button = document.getElementsByClassName ('button');
     button.addEventListener('click', () => {
     // do whatever you want here
        });
   </script>
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!