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!
Use the
:last-childselector instead to get the one in each<thead>, like this: