开发者

jQuery fadeOut() function doesn't ALWAYS work in Chrome, Firefox, IE

Sometimes, the slideshow on my website, which uses fadeOut and fadeIn to cycle through three main images will fadeIn a new photo without fading the old one. This doesn't happen every time the page loads though. My site is here (the slideshow will take 7 seconds to change): http://codersarepeople.com/v2/

The code I use is this

slideshow = new Array('#slideshow1','#slideshow2','#slideshow3');
var i = Math.floor(Math.random()*3);
$(slideshow[i]).开发者_开发知识库fadeIn(125);
var t = setInterval(function() {
 $(slideshow[i%3]).fadeOut(250,function() {
  $(slideshow[(i+1)%3]).fadeIn(250);
 });
 i++;
},7000);


It turns out, the error only occurs when the random variable i = 0. I just cheated and forced it to either equal 1 or 2. I still don't know why that was happening though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜