How do I add 'last' to the last article?
$("body.page-template-testimonials-php article:last-child").addClass("last");
That's the co开发者_StackOverflowde I'm using to target the last article on the page. However, it's not working. What am I doing wrong?
Here is the markup: http://pastebin.com/m6nHxEQh
I think it would be easier if you used:
$("#content article:last").addClass("last");
Since I don't see the body.page-template-testimonials-php class anywhere.
$('body.page-template-testimonials-php article').last().addClass('last');
Use .eq() to filter before applying class:
$("body.page-template-testimonials-php article").eq(-1).addClass("last");
精彩评论