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

271
Views
How to trigger an event (together) in JavaScript?

i have created an EventListener for each button but i have button generation all and i need to call all events at once.I tried to put everything inside a function, but I don't know how to activate all events. I would be very grateful for any help

enter image description here

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

0

You can just call HTMLElement.click() on everyelement to simulate the click on every element. You can read more about it here: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click

buttonAll.addEventListener('click', ()=> {
    nameButton.click();
    balanceButton.click();
    ageButton.click();
    documentButton.click();
    levelButton.click();
    buttonClear.click();
})

if the list can grow then you might want to group the elements in an array to keep the function short

let buttonAllTargets = [
    nameButton,
    balanceButton,
    ageButton,
    documentButton,
    levelButton,
    buttonClear
];

buttonAllTargets.forEach(element => element.click());
buttonAll.addEventListener('click', ()=> {
    buttonAllTargets.forEach(element => element.click());
})
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!