The problem of choosing jQuery (the first TD in each TR in the table)

I am trying to add a css class to the first td (cell) (and no other td) of each tr (row) in my table.

Can someone help me with a jQuery selector for this?

Thanks!

+7
jquery jquery-selectors
source share
1 answer

Use the first-child selector:

$("table tr td:first-child").text("I am the first child of the row"); 

A small test: http://jsfiddle.net/WxzfQ/

+10
source share

All Articles