Reputation: 55
I want to target the second <tr>
and the second <td>
tag using JQuery. I know I could give the <td>
tag a class and just target that one but I want to do it this way. This is what I've got so far:
$('#playlist tr:nth-child(2)');
<table id="playlist">
<tr class="bold">
<td>ID:</td>
<td>Track-Name:</td>
<td>Artist:</td>
<td>Duration:</td>
</tr>
<tr>
<td class="idD">1</td>
<td id="first" song="Weown.mp3" cover="cover.jpg" artist="The Wanted">We Own The Night</td>
<td>The Wanted</td>
<td class="idD">3:25</td>
</tr>
</table>
Upvotes: 0
Views: 46
Reputation: 5264
Above answers are correct but you can also use eq()
$("#playlist tr").eq(2).find('td').eq(2);
check the demo on jsFiddle
Upvotes: 0
Reputation: 23816
Consider following:
$('#playlist tr:nth-child(2) td:nth-child(2)')
//or
$('#playlist tr:eq(1) td:eq(1)')
Details: :nth-child(), :eq()
Upvotes: 1