views:

143

answers:

2

Hi,

Is there a way in jQuery using selectors to identify the penultimate element?

Is there something like a :last-1?

The list can be any length so i cant use 'eq'

Any help would be much appreciated.

A.

+1  A: 

Can't you just get the last element and then use .prev() to get the penultimate element?

If you can post your HTML it would help.

Mark B
+6  A: 

Can't see your html but try this:

$("a:last").prev();

That should give you the one before the last element.

You could even try this:

$("a:last").eq(-1);
Sarfraz