Alex
Alex

Reputation: 77389

jQuery Selector Problem (First TD in each TR in a table)

I'm 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 the jQuery selector for this please?

Thank you!

Upvotes: 7

Views: 7124

Answers (1)

karim79
karim79

Reputation: 342795

Use the first-child selector:

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

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

Upvotes: 10

Related Questions