jQuery selector first td of each row -
i have stuff:
<table> <tr> <td>nonono</td> <!-- find --> </td>foobar</td> </tr> <tr> <td>nonono2</td> <!-- find --> </td>foobar2</td> </tr> <tr> <td>nonono3</td> <!-- find --> </td>foobar2</td> </tr> </table>
i have tried $('td:first')
no luck;
expected return: <td>nonono</td>
, <td>nonon2</td>
, <td>nonon3</td>
thanks in advance!
you should use :first-child
instead of :first
:
sounds you're wanting iterate through them. can using .each()
.
example:
$('td:first-child').each(function() { console.log($(this).text()); });
result:
nonono nonono2 nonono3
alernatively if you're not wanting iterate:
$('td:first-child').css('background', '#000');
Comments
Post a Comment