Search code examples
jqueryhtmlchildren

JQuery targeting child


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>

Solution

  • This would be:

    $('#playlist tr:nth-child(2) td:nth-child(2)'); 
    

    http://jsfiddle.net/kzwbkfz3/