Reputation: 11820
HTML:
<table id="table">
<thead>
</thead>
<tbody>
<tr>
<td>5</td>
<td>9</td>
</tr>
<tr>
<td>3</td>
<td>7</td>
</tr>
</tbody>
</table>
jQuery selector:
$('#table td:nth-child(1)')
which returns:
<td>5</td>
why doesn't it return <td>5</td>
AND <td>3</td>
? I want the whole nth
(1st here) column.
Thanks.
Upvotes: 2
Views: 70
Reputation: 1326
This works. For first child i recommend :first-child
$('#table tr').each(function(){
$('td:nth-child(1)', this).css( 'color', 'red' )
});
Upvotes: 0
Reputation: 44740
$('#table td:nth-child(1)').each(function(){
// <td>5</td> AND <td>3</td>
});
This was just to display the element's returned by the selector
And what you did is absolutely correct $('#table td:nth-child(1)')
see here
Upvotes: 2