title: Linking a button to a list element in ejs
body: <p>I have a array of <code>answer</code> objects and I am using a for loop in ejs to display them to the user. An answer object has an <code>id</code>, a <code>text</code> and a boolean <code>correct</code> attribute.</p>
  
  <pre><code>&lt;% answers.forEach((answer)=&gt;{ %&gt;
    &lt;li&gt;
      &lt;p&gt;&lt;%=answer.text%&gt;&lt;/p&gt;
      &lt;button&gt;CORRECT&lt;/button&gt;
    &lt;/li&gt;
  &lt;%})%&gt;
  </code></pre>
  
  <p>I want a user to be able to click on the correct answer and have my script send the <code>id</code> of the answer that was clicked to the server so I can update the <code>correct</code> attribute for that specific answer in my Mongo database. Possibly something like:</p>
  
  <pre><code>$(the_button_clicked).click((event)=&gt;{
    $.ajax({
      sending the correct answer to the database
    });
  });
  </code></pre>
  
  <p>The problem is that this is a list and I don't know how to link each specific answer to its correct button. I can probably add a class or id to the button element and set it to <code>answer.id</code> but I'm wondering if there is a better way of doing it. I feel like this should be a common pattern.      </p>