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!
The :first selector selects the first element. Note: This selector can only select one single element. Use the :first-child selector to select more than one element (one for each parent). This is mostly used together with another selector to select the first element in a group (like in the example above).
The following code shows how to select the first row in a table $("tr:first").
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With