Reputation: 59
The code have to work with ie so :last is not an option
<table class="ms-main" cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
<tr>..</tr>
<tr>..</tr>
<tr>..</tr>
<tr class=add this value including class=>..</tr>
</table>
Thank you in advance
EDIT1:
How about if the source file is this?
<table class="ms-main" cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
<tr>..</tr>
<tr>..</tr>
<tr>..</tr>
<tr class=add this value including class=>**<table>more nested tables here</table>**</tr>
</table>
Upvotes: 2
Views: 3540
Reputation: 129782
:last
does work in IE.
jQuery implements this manually, it has no relation to the css selectors supported by the browser.
$('.ms-main tr:last').addClass('name-of-class');
Here's a nice article on jQuery's implementation of the sizzle selector and use of querySelectorAll
As for your edit, you may want to use >
to denote that the tr
should be an immediate child, and not a more distant descendant.
$('.ms-main > tr:last')
Look out for tbody
, though.
Upvotes: 1
Reputation: 2000
$('table tr').last().addClass('myClass');
Selector :last-child
is not supported in IE 6-8, use method last() to find last element in DOM
Upvotes: 0