tags:

views:

26

answers:

1

On a single page, I have two tables. Each of them has a class of "data". Each of them has theads.

I want to apply formatting to the last row in each of the table's theads.

I originally had this:

$('table.data thead tr:last').children().addClass('col');

Which works fine if there is only one table on the page. But if there are multiple tables, that tr:last selector picks up the last tr for ALL of the tables matching the class, not EACH table.

How do I constrain this to operate on the last tr for each thead?

Thanks!

+1  A: 

Use the :last-child selector instead to get the one in each <thead>, like this:

$('table.data thead tr:last-child').children().addClass('col');
//or possibly:
$('table.data thead tr:last-child > td').addClass('col');
Nick Craver
perfect. Thanks a lot, Nick
marc esher
@marc - welcome :)
Nick Craver