3
如何測試圖像是一組圖像中的第一個還是最後一個?如果一個div是第一個孩子,jQuery測試?
我試圖做一個和下一個按鈕在動畫或縮小取決於我是否在一系列圖像用下面的代碼的末尾:
var $current = jQuery("img .active");
var $next = $current.next();
if ($next != jQuery("img:first-child")
{
// show next item and the previous button
// seems to work?
} else if ($next == jQuery("img:last-child")
{
// hide the next button since we're at the end
// doesn't seem to work??
}
什麼是id選擇器'#img'在做什麼?是否有一個ID爲'img'的元素保存圖像?或者應該只是簡單的'img'?另外,你的意思是'img.active',它將是'active'類的img元素嗎? – theazureshadow 2010-12-16 05:21:17
對不起,這是一個錯字,我只是糾正它。 – redconservatory 2010-12-16 15:54:27