Why is this not working $(this).parents("tr").find("td:eq(2)").html()
I cant seam to get the text “getthis” relative to the td tr that called it
<table>
<tr>
<td>1</td>
<td>getthis</td>
<td onclick="$(this).parents("tr").find("td:eq(2)").html()">4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>getthis</td>
<td onclick="$(this).parents("tr").find("td:eq(2)").html()">4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>getthis</td>
<td onclick="$(this).parents("tr").find("td:eq(2)").html()">4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>getthis</td>
<td onclick="$(this).parents("tr").find("td:eq(2)").html()">4</td>
<td>5</td>
</tr>
</table>
You are using double-quotes too much. When creating a string in line, you are accidentally ending the
onclickattribute. Also,eqis zero-indexed, so you want1instead.Better (but only because it works):
Best: