tags:

views:

68

answers:

2

I do not get anything in return when passing -1 to .eq() on a jQuery object. This, from the firebug console, shows my problem.

>>> test
jQuery(div#462601759.belt, div#43773862.belt, div#1973215028.belt, div#1811434128.belt, div#486504966.belt, div#100019133.belt, div#1928403755.belt, div#313171064.belt, div#1705880802.belt, div#1964159344.belt, div#1813766347.belt, div#91768319.belt, div#454873181.belt, div#477172806.belt, div#34963942.belt, div#1920955753.belt)
>>> test.eq(-1)
jQuery()
>>> test.eq(-2)
jQuery(div#34963942.belt)

Any ideas?

+1  A: 

According to the docs for eq(), if you pass in an out of range value (e.g. -1) you will get back an empty jQuery object.

Or are you looking for the :eq selector?

On a related note, HTML id's should not start with a digit (W3C) (there's also IE bugs that crop up if you try). You should prefix them with an alpha value.

scunliffe
+2  A: 

This is a jQuery 1.4 feature (see release notes, docs)

Znarkus
Thank you! The problem was an out of date, compared to the documentation, jQuery copy.
nibbo