[英]jQuery slider next prev button issue
I'm trying to make a simple slider with prev and next buttons. 我正在尝试使用上一个和下一个按钮制作一个简单的滑块。 The slider works fine and the next button functions alright, but as you can see the prev button is wonky: 滑块可以正常工作,并且下一个按钮可以正常使用,但是您可以看到上一个按钮很奇怪:
invNext.on('click', function PreviousPic() {
var currentPic = $('.img-nav-container > img');
$(currentPic).fadeOut(1000, function () {
// fadeIn the previous image in the array
var img = imgArr[(currIndex - 1)]; // not working
$("#slider").attr("src", img);
GetNewImage();
$("#slider").fadeIn(1000);
});
http://jsfiddle.net/davidpm/5TsL6/ http://jsfiddle.net/davidpm/5TsL6/
I made a jsfiddle since it will be more helpful to see everything thats going on. 我做了一个jsfiddle,因为它可以帮助您了解所有发生的事情。 What am I missing? 我想念什么? Also, I'd appreciate any help refactoring this mess. 另外,我希望能为您提供帮助,以帮助您解决这一难题。 I'm still very much a newbie with jQuery... 我仍然是jQuery的新手...
Thanks in advance, 提前致谢,
-D -D
Try this, 尝试这个,
invNext.on('click', function PreviousPic() {
var currentPic = $('.img-nav-container > img');
$(currentPic).fadeOut(1000, function () {
// fadeIn the previous image in the array
var img = imgArr[(currIndex - 2)]; // not working
$("#slider").attr("src", img);
GetNewImage();
$("#slider").fadeIn(1000);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.