0
干草,我已经写了使用jQuery一个简单的褪色画廊。它基本上是循环一组图像,从一个到另一个渐变。它完美的作品,如预测,直到获得最后一个图像,然后,它不会从最后消失在第一,只是为了显示它。jQuery的褪色画廊
,这里是我的jQuery
$(document).ready(function(){
Zindex = 99999;
i = 0;
$(".flash img").each(function(){
$(this).css({
'position':'absolute',
'z-index':Zindex,
'display':'none'
});
Zindex--;
});
$(".flash img:first").show();
doFade = function(){
if(i == 6) { i = 0; };
$(".flash img:eq("+parseInt(i+1)+")").fadeIn(100);
$(".flash img:eq("+parseInt(i)+")").fadeOut(1000);
setTimeout("doFade()", 2000);
i++;
};
doFade();
});
注:这里只有永远将是7张图片。
而且我的标记
<div class='flash'>
<img src="img/gallery/picture1.jpg" width="780" height="253" alt="Picture1">
<img src="img/gallery/picture2.jpg" width="780" height="253" alt="Picture2">
<img src="img/gallery/picture3.jpg" width="780" height="253" alt="Picture3">
<img src="img/gallery/picture4.jpg" width="780" height="253" alt="Picture4">
<img src="img/gallery/picture5.jpg" width="780" height="253" alt="Picture5">
<img src="img/gallery/picture6.jpg" width="780" height="253" alt="Picture6">
<img src="img/gallery/picture7.jpg" width="780" height="253" alt="Picture7">
</div>
我认为问题出在线路
if(i == 6) { i = 0; };
任何具体的原因,你不使用周期插件,你写你自己的作用? http://www.malsup.com/jquery/cycle/ – 2009-11-06 10:19:46
都能跟得上。循环插件工作出色。我已经迁移到那。任何想法对我的代码的问题,但? – dotty 2009-11-06 10:27:05