我在1个网站上使用此代码3个画廊。每个画廊都有其他图片。问题是第一个画廊在循环中工作,但第二个和第三个画廊在一个循环后停止。使用javascript的画廊! 1个网站上的3个画廊
<script type="text/javascript">
function cycleImages(){
var $active = $('#cycler .active');
var $next = ($active.next().length > 0) ? $active.next() : $('#cycler img:first');
$next.css('z-index',2);//move the next image up the pile
$active.fadeOut(1700,function(){//fade out the top image
$active.css('z-index',1).show().removeClass('active');//reset the z-index and unhide the image
$next.css('z-index',3).addClass('active');//make the next image the top one
});
}
$(document).ready(function(){
// run every 4s
setInterval('cycleImages()', 5000);
})</script>
如果你把小提琴/与代码codepen演示你有什么人都更愿意和能够提供帮助。 – surfmuggle
我希望这个小提琴包含所有代码那nessasary – donbenni
问题upvote添加小提琴 – surfmuggle