开发者

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");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜