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'); 

jsfiddle demo.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -