我在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