title: How to create a JS function on a dynamically generated Rails table
body: <p>I'm trying to create a JS function to increment the count of the vote on the page, which I would usually do by writing <code>Document.getElementByID</code> and then writing in the ID, but in Rails, I am trying to figure out how to write this function where the table rows are being created dynamically in a loop. How would I create a function to do this?</p>
  
  <p>Here's the html rails loop:</p>
  
  <pre><code>  &lt;tbody&gt;
      &lt;% @requests.each do |request| %&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;%= request.artist %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= request.title %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= request.voteCount %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;button onclick="upVote()"&gt;Vote&lt;/button&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;% end %&gt;
    &lt;/tbody&gt;
  </code></pre>