0
我已經開始設置幻燈片放映的下一個和上一個按鈕,它似乎並沒有工作。它沒有完成,但下一個和prev按鈕應該工作。jQuery幻燈片的下一個和上一個
var timer;
var slides = 5;
var timeLen = 5000;
function nextSlide(){
clearTimeout(timer);
var current= parseInt($("#counter").html());
if(current < slides){
var nextSlide = current + 1;
} else {
var nextSlide = 1;
}
// set rear image to next slide
$("#slide_back img").attr("src","http://daduber.com/ss2/" + nextSlide + ".jpg");
// hide front image
$("slide_front").animate({opacity: "0"},700,"linear",function(){
// change front image src(currently hidden)
$("#slide_front img").attr("src","http://daduber.com/ss2/" + nextSlide + ".jpg");
$("slide_front").animate({opacity: "0"}, 700, "linear", function(){
// display front image
$("#slide_front").css("opacity","1");
// change jumpers
$("#jumpers li.current").removeAttr("class");
$("#jumpers #" + nextSlide).attr("class","current");
// update counter
$("#counter").html(nextSlide);
// set timer for next image
timer = setTimeout("nextSlide()", timeLen);
});
}
$(document).ready(function(){
timer = setTimeout("nextSlide()", timeLen);
});
在我看來,它與回調函數在動畫的東西。 如果我將其替換爲 $(「slide_front」)。animate({opacity:「0」},700); 其作品,未經動畫