title: jQuery using multiple buttons of the same class to return a value
body: <p>I have a list of entries generated by PHP, each in its own div and each with a unique ID. I'm trying to develop an AJAX call that can remove each entry based on their ID, however whenever I run the script below, it always returns 0.</p>
  <pre><code>&lt;div&gt;
      Some entry here
      &lt;button id=&quot;0&quot; class=&quot;remove&quot;&gt;Remove&lt;/button&gt;
  &lt;/div&gt;
  &lt;div&gt;
      Another entry here
      &lt;button id=&quot;1&quot; class=&quot;remove&quot;&gt;Remove&lt;/button&gt;
  &lt;/div&gt;
  // ... and so on
  
  &lt;script&gt;
      $(&quot;.remove&quot;).click(function() {
          var id = $(&quot;.remove&quot;).attr('id');
          alert(id); // debug
          // AJAX call here
      });
  &lt;/script&gt;
  </code></pre>
  <p>Previously I tried the same thing except for the other way around - the id returned by PHP was in the class attribute and the id attribute had the value 'remove' and this only returned 0 for the first button. The second button didn't invoke the jQuery script at all.</p>
  <p>How can I pass a unique ID to the same jQuery call?</p>