Jquery 以前的不起作用 var-currentImage; var currentIndex=0; 函数showImage(索引){ 如果(索引
“上一步”按钮有问题。当我到达第一个图像后,它停止工作,我的意思是他不会滑到最后一个图像。我真的不知道是什么问题,请帮忙。(下一步按钮工作正常)如果从第一张图像返回一个stap,则必须将新索引设置为最后一张图像,而不是第一张图像,在函数中,您始终将图像设置为0Jquery 以前的不起作用 var-currentImage; var currentIndex=0; 函数showImage(索引){ 如果(索引,jquery,slideshow,Jquery,Slideshow,“上一步”按钮有问题。当我到达第一个图像后,它停止工作,我的意思是他不会滑到最后一个图像。我真的不知道是什么问题,请帮忙。(下一步按钮工作正常)如果从第一张图像返回一个stap,则必须将新索引设置为最后一张图像,而不是第一张图像,在函数中,您始终将图像设置为0 var currentImage; var currentIndex = 0; function showImage(index){ if(index < $('#backimg img').length){
var currentImage;
var currentIndex = 0;
function showImage(index){
if(index < $('#backimg img').length){
var indexImage = $('#backimg img')[index]
if(currentImage){
if(currentImage != indexImage ){
$(currentImage).css('z-index',2);
$(currentImage).fadeOut(250, function() {
$(this).css({'display':'none','z-index':1})
});
}
}
$(indexImage).css({'display':'block', 'opacity':1});
currentImage = indexImage;
currentIndex = index;
$('#thumbs li').removeClass('active');
$($('#thumbs li')[index]).addClass('active');
}
}
function showNext(){
var len = $('#backimg img').length;
var next = currentIndex < (len-1) ? currentIndex + 1 : 0;
showImage(next);
}
function showPrev(){
var len = $('#backimg img').length;
var next = currentIndex > 0 ? currentIndex - 1 : 0;
showImage(next);
}
$(document).ready(function() {
showNext();
showPrev();
$('#thumbs li').bind('click',function(e){
var count = $(this).attr('rel');
showImage(parseInt(count)-1);
});
$('#prev a').click(function () {
showPrev();
});
$('#next a').click(function () {
showNext();
});
});
你能发布html吗?我认为你的方法可能是复杂的,也许是不必要的…它正在工作!但是可以为图像插入预加载程序?当然,这是一个不同的主题,预加载程序有很多可能的实现-请参阅:
function showPrev(){
var len = $('#backimg img').length;
var next = currentIndex > 0 ? currentIndex - 1 : len-1 ;
showImage(next);
}