我创建了一个 jQuery 幻灯片放映,我需要知道如何向其中添加下一个和上一个按钮。我将不胜感激任何帮助
$(document).ready(function(){
var nextSlide = $("#slides img:first-child");
var nextCaption;
var nextSlideSource;
var timer;
$("#featuredSlider").mouseenter(function(){
if (timer) { clearInterval(timer) }
});
$("#featuredSlider").mouseleave(function(){
timer = setInterval(
function(){
$("#caption").fadeOut(1000);
$("#slide").fadeOut(1000,
function(){
if (nextSlide.next().length == 0) {
nextSlide = $("#slides img:first-child");
}
else{
nextSlide = nextSlide.next();
}
nextSlideSource = nextSlide.attr("src");
nextCaption = nextSlide.attr("alt");
$("#slide").attr("src", nextSlideSource).fadeIn(1000);
$("#caption").text(nextCaption).fadeIn(1000);
})
},3000);
})
.mouseleave();
});