title: How do I get the current row index of my table using Jquery?
body: <p>So I am trying to get the row index of my table using Jquery, however my code returns the same index number for every single row. I need to find the index to remove the selected row. However this code only removes the last value
  What I have tried so far: </p>
  
  <pre><code>function updateCredentialList() {
      var index = $('.existingCredential').find('tr').closest('tr').index();
      var i = $('.existingCredential').find('tr:eq('+index+')').remove();
      alert(index);   
   }
  </code></pre>
  
  <p>My table: </p>
  
  <pre><code>&lt;c:choose&gt;
              &lt;c:when test="${action == 'edit'}"&gt; 
              &lt;td class="data"&gt;
              &lt;input type="hidden" name="pkAdminCredentials" value="${environment.pkAdminCredentialIds}"&gt;
              &lt;input type="hidden" name="dbCredentials" value="${environment.dbCredentialIds}"&gt;
              &lt;table class="existingCredential"&gt;
              &lt;tr&gt;
                  &lt;th&gt;Primary?&lt;/th&gt;
                  &lt;th&gt;Username&lt;/th&gt;
                  &lt;th&gt;Password&lt;/th&gt;
                  &lt;th&gt;ID&lt;/th&gt;
              &lt;/tr&gt;
              &lt;c:forEach var="each" items="${environment.pkAdminCredentials}"&gt;
              &lt;tr&gt;
                  &lt;td class="edit"&gt;${each.primary ? 'Yes' : 'No'&lt;/td&gt;
                  &lt;td class="edit"&gt;${each.username}&lt;/td&gt;
                  &lt;td class="edit"&gt;${each.password}&lt;/td&gt;
                  &lt;td class="edit"&gt;${each.id}&lt;/td&gt;
                  &lt;td&gt;&lt;a class="editCredential" class="openWindow" data-modal-id="existingCredential" data-credential-id="${each.id}"&gt;Edit&lt;/a&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;a href="#"&gt;Delete&lt;/a&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;/c:forEach&gt;
              &lt;/table&gt;
              &lt;/td&gt;
              &lt;/c:when&gt;
   &lt;/c:choose&gt;
  </code></pre>