4

我目前正在使用 jquery 循环插件。我有 3 个不同的幻灯片,它们彼此相邻并同时循环播放。我想做的是先关闭第一个幻灯片,然后是第二个,然后是第三个。无论如何我可以通过增量或超时来做到这一点吗?

<div class="cycle" id="one">
   <img src="one.jpg" alt="" />
   <img src="two.jpg" alt="" />
   <img src="three.jpg" alt="" />
</div>
<div class="cycle" id="two">
   <img src="two.jpg" alt="" />
   <img src="three.jpg" alt="" />
   <img src="one.jpg" alt="" />
</div>
<div class="cycle" id="three">
   <img src="three.jpg" alt="" />
   <img src="one.jpg" alt="" />
   <img src="two.jpg" alt="" />
</div>

$('.cycle').cycle({
   fx:'fade',
   speed:1000
});
4

2 回答 2

3
var timeout = 0;

$(".cycle").each(function () {
   var $this = $(this);
   setTimeout(function () {
      $this.cycle({
         fx: "fade", speed: 1000
      });
   }, timeout);

   timeout += 2000;
});
于 2013-01-21T16:48:36.037 回答
1
var i = 1;
var x = $(".cycle").length;
var w = setInterval( function() {
if(i==x) {
window.clearInterval(w);
}
else {
$(".cycle:nth-child('+i+')").cycle({
   fx:"fade",
   speed:1000
});
i++;
}
}, 3000);
于 2013-01-21T16:48:43.733 回答