views:

74

answers:

2

Hi,

I use a jquery selector :

$('#menus>ul>li>a')

I'd like to to iterate the selector result without the last one:

$('#menus>ul>li>a').removeLast().each(fct());

Ofcourse the function "removeLast()" doesn't exist, is there an equivalent ?

Thanks.

+8  A: 

Use a combination of the :not and :last selectors:

$('#menus > ul > li > a:not(:last)')

Jimmy Cuadra
Beat me to it :))
nc3b
or use the function `$(...).not(':last')...`
stereofrog
+2  A: 

You can use the :not selector or the .not() method:

$('#menus>ul>li>a:not(:last)')

or

$('#menus>ul>li>a').not(":last")
RoToRa
The parameter to `not` in your second example should use a `:` instead of a `.`.
Jimmy Cuadra
Oops, thank you.
RoToRa