我製作了一個小幻燈片腳本來循環顯示圖像列表。它的問題是在next()和prev()函數中選擇當前索引。幻燈片的jQuery圖像索引
查看幻燈片時,它會執行一次太多的next(),導致沒有圖像顯示在一張幻燈片上。該指數太高。當單擊上(),它似乎坐在0指數(無圖像有)的點擊幾下,然後踢回在7
這裏是jQuery代碼
jQuery('.slideshow').css({'position': 'relative', 'width': 240, 'height': 263}).find('img').css('display', 'none');
jQuery('.slideshow').find('img').eq(startingSlide).css('display', 'block');
jQuery('.slideshow span').click(function()
{
if (jQuery(this).hasClass('span2'))
{
var currentSlide = jQuery('.slideshow img:visible').prevAll().length;
jQuery('.slideshow').find('img').eq(currentSlide)
.css('display', 'none').next('img').css('display', 'block').css({top: -300, left: 0}).animate({top: 0, left: 0}, 2000, 'easeOutBounce');
}
else
{
var currentSlide = jQuery('.slideshow img:visible').prevAll().length;
jQuery('.slideshow').find('img').eq(currentSlide)
.css('display', 'none').prev('img').css('display', 'block').css({top: 300, left: 0}).animate({top: 0, left: 0}, 2000, 'easeOutBounce');
}
});
關於如何解決任何想法索引?
請確保在測試之前獲取最新的副本,我的代碼中有錯誤...我剛糾正! –