似乎无法弄清楚为什么我的幻灯片放映时间在本页的第二部分中关闭。它几乎表现得不稳定。我检查了剧本,时间似乎是正确的。幻灯片放映位于本页的第二部分:
向下滚动。
这是页面:
http://mudchallenger.com/fullpage/examples/a-test-5.html
我正在尝试让 2 秒淡入淡出,并且每个图像保持 5 秒。
<div id="candy-wrapper">
<div id="candy-slideshow">
<div><img src="imgs/bg-fire.jpg" height="auto" width="100%"></div>
<div><img src="imgs/bg-runstart.jpg" height="auto" width="100%"></div>
<div><img src="imgs/bg-ice.png" height="auto" width="100%"></div>
<script>
$("#candy-slideshow > div:gt(0)").hide();
setInterval(function() {
$('#candy-slideshow > div:first')
.fadeOut(2000)
.next()
.fadeIn(2000)
.end()
.appendTo('#candy-slideshow');
}, 5000);
</script>
谢谢
最佳答案
像这样改变时间
setInterval(function() {
$('#candy-slideshow > div:first')
.fadeOut(2000)
.next()
.fadeIn(2000)
.end()
.appendTo('#candy-slideshow');
}, 5000);
setInterval 中的第二个参数表示时间(以毫秒为单位)。如果改为5000则表示5秒后才会执行next方法。
关于javascript - 幻灯片定时关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24378823/