开发者

How do I add 'last' to the last article?

开发者 https://www.devze.com 2023-02-10 16:39 出处:网络
$(\"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.
$("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");
0

精彩评论

暂无评论...
验证码 换一张
取 消