I have a table with rows generated via a loop. Each TR has a unique ID.
How do I select that ID when I click span with .clickMe class?
<tr id="244">
<td>...</td>
<td><span class="clickMe"</td>
</tr>
<tr id="4554">
<td>...</td>
<td><span class="clickMe"</td>
</tr>
IF the structure is always going to be the same you could just do:
var theId = this.parentNode.parentNode.idIf its not always going to be the same then you could do:
var theId = $(this).closest('tr').attr('id');So putting it all together:
Also your Id’s should not begin with numbers as per the spec.