Japeljoff Japeljoff - 1 year ago 79
jQuery Question

How to call two nth-child in a table?

I have a table 4*5 (4 columns, 5 rows).

I want to add a class to the cells on the first column and after the 2nd row.

My code :

$("tr>td:nth-child(1) tr:nth-child(n+3)").addClass("ClassName");

This is not working. Any idea on how to do this?

PS. JsFiddle

Answer Source

To select cells that are both at the first column and after the 2nd row, use the CSS selector:

tr:nth-child(n+3) td:nth-child(1)


$("tr:nth-child(n+3) td:nth-child(1)").addClass("ClassName");

Your fiddle, updated: http://jsfiddle.net/CnUw6/1/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download