title: Can I pass an argument to the function in an event handler?
body: <p>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 <code>i</code> into my handlers.</p>
  <pre><code>for (let i = 0; i &lt; number_of_carousels; i++){
      prev_button_list[i].addEventListener(&quot;touchend&quot;, handleMoveToPrevSlide(i));
      next_button_list[i].addEventListener(&quot;touchend&quot;, handleMoveToNextSlide(i));
  }
  </code></pre>
  <p>Also, I got the lists of elements with the following:</p>
  <pre><code>prev_button_list = document.getElementsByClassName(&quot;carousel-prev&quot;);
  next_button_list = document.getElementsByClassName(&quot;carousel-next&quot;);
  </code></pre>
  <p>Maybe I'm missing something?</p>