jQuery Slideshow Next / Previous
我是jQuery的新手,我只是想知道创建下一个/上一个按钮来浏览幻灯片的最简单和最有效的方法。 我的代码如下:
run = setInterval("switchSlide()", 2000);
$(document).ready(function() {
$('#slideshow img:gt(0)').hide();
$('#slideshow').hover(function() {
clearInterval(run);
}, function() {
run = setInterval("switchSlide()", 2000);
});
$('#play').click(function() {
run = setInterval("switchSlide()", 2000);
});
$('#stop').click(function() {
clearInterval(run);
});
$('#previous').click(function() {
$('#slideshow img:first').fadeOut(1000).prev().fadeIn(1000).end().appendTo('#slideshow');
});
$('#next').click(function() {
$('#slideshow img:first').fadeOut(1000).next().fadeIn(1000).end().appendTo('#slideshow');
});
});
function switchSlide() {
$('#slideshow img:first').fadeOut(1000).next().fadeIn(1000).end().appendTo('#slideshow');
}
我假设下一个()会让你下一个图像,因为这是你在switchSlide()中所做的。 您可以在HTML中添加div元素
<div id="next"></div>
然后附加一个click事件,它将调用next(),基本上执行与switchSlide()相同的操作
$('.next').click(function(){
$('#slideshow img:first').fadeOut(1000).next().fadeIn(1000).end().appendTo('#slideshow');
})
以前也可以做同样的事情
链接地址: http://www.djcxy.com/p/64759.html上一篇: jQuery Slideshow Next/Previous
下一篇: jQuery Banner cancel function when mouseenter over a button
