I have a table that is generated dynamically. And a click event on a button in one of the rows. I need to get the values of the labels with classes ‘label1’ and ‘label2’ in the row that the button is clicked. here is example html:
<table>
<tbody>
<tr>
<td><label class="label1">test row 1 - label 1</label></td>
<td><label class="label2">test row 1 - label 2</label></td>
<td><input type="button" id="btnTest1" class='btn' value="Click me" /></td>
</tr>
<tr>
<td><label class="label1">test row 2 - label 1</label></td>
<td><label class="label2">test row 2 - label 2</label></td>
<td><input type="button" id="btnTest2" class='btn' value="Click me" /></td>
</tr>
</tbody>
</table>
I can get the parent row by doing this: $(this).closest('tr') but then How do I chain that to get the 2 labels in the row thats clicked?
or if you’re sure, there won’t be any unneeded labels: