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

128
Views
Can I pass an argument to the function in an event handler?

I have a bunch of previous and next buttons on more multiple mobile carousels on the same page, and I'd like to assign event handlers to the previous and next buttons of each carousel for when they're touched. However, chrome's mobile emulator doesn't respond to any touches, and I think it may be a problem with passing the value of i into my handlers.

for (let i = 0; i < number_of_carousels; i++){
    prev_button_list[i].addEventListener("touchend", handleMoveToPrevSlide(i));
    next_button_list[i].addEventListener("touchend", handleMoveToNextSlide(i));
}

Also, I got the lists of elements with the following:

prev_button_list = document.getElementsByClassName("carousel-prev");
next_button_list = document.getElementsByClassName("carousel-next");

Maybe I'm missing something?

about 4 years ago · Juan Pablo Isaza
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!