2010-01-26 64 views
1

在jQuery對象上傳遞-1.eq()時我沒有收到任何回報。這從螢幕控制檯顯示我的問題。.eq(-1)在jquery對象上不返回任何內容

>>> 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) 

任何想法?

+0

你可以嘗試更新您的jQuery庫。我只是在jQuery網站上的firebug中測試過它,它在那裏工作。 – 2010-01-26 17:45:13

回答

2

這是一個jQuery 1.4功能(見release notesdocs

+0

謝謝!問題已經過時,與文檔,jQuery副本相比。 – 2010-01-26 18:39:01

1

根據eq()的文檔,如果您傳入的值超出範圍(例如-1),您將返回一個空的jQuery對象。

或者您在尋找:eq選擇器?

在相關說明中,HTML編號爲should not start with a digit (W3C)(如果您嘗試,也會出現IE錯誤)。你應該爲它們加上一個alpha值。

相關問題