获得倒数第二个元素 [英] Get penultimate element
本文介绍了获得倒数第二个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在jQuery使用选择器来识别倒数第二个元素?
Is there a way in jQuery using selectors to identify the penultimate element?
有什么像a:last-1吗?
Is there something like a :last-1?
列表可以是任何长度,所以我不能使用'eq'
The list can be any length so i cant use 'eq'
任何帮助将非常感激。
A。
推荐答案
无法看到您的HTML,请尝试:
Can't see your html but try this:
$("a:last").prev();
这应该给你最后一个元素之前。
That should give you the one before the last element.
您甚至可以尝试:
$("a:last").eq(-1);
这篇关于获得倒数第二个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文