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 Document.getElementByID 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?
Here's the html rails loop:
<tbody>
<% @requests.each do |request| %>
<tr>
<td><%= request.artist %></td>
<td><%= request.title %></td>
<td><%= request.voteCount %></td>
<td><button onclick="upVote()">Vote</button></td>
</tr>
<% end %>
</tbody>