Finding nth-child of siblings via jQuery

Posted by DA on Stack Overflow See other posts from Stack Overflow or by DA
Published on 2010-03-15T22:05:00Z Indexed on 2010/03/15 22:09 UTC
Read the original article Hit count: 271

Filed under:
|

Let's say I have two tables that look like this:

TH   TH   TH   TH  
TD   TD   TD   TD  
TD   TD   TD   TD  

and

TH   TH   TH   TH  
TH   TD   TD   TD  
TH   TD   TD   TD  

I'd like to select the 3rd column in each.

At first I was using nth-child as such:

$('table tr td:nth-child(3)')

But that's not going to work, as 3rd TD is in a different column in each table.

What I need in pseudo code is 'get the 3rd TD or TH in each row'.

I assume I need to use $.siblings but not entirely sure.

© Stack Overflow or respective owner

Related posts about nth-child

Related posts about jQuery