我有以下幻灯片代码:
HTML
<div id="slideshow"><img src="common/images/background/Slide1b.jpg" />
<img src="common/images/background/Slide2b.jpg" />
<img src="common/images/background/Slide3b.jpg" />
<img src="common/images/background/Slide4b.jpg" />
</div>
jQuery
var opt1 = 1;
$(document).ready(function() {
$('#slideshow').supersize();
all_images = $('#slideshow > img');
all_images.hide();
first = $('#slideshow > img:eq(0)');
first.show().attr('class', 'power');
setInterval(function() {
var total = $('#slideshow > img').length;
if(opt1 < total) {
var current = $('.power');
var next = $('.power').next();
current.removeClass('power').fadeOut('slow');
next.fadeIn('slow').addClass('power');
++opt1;
} else {
opt1 = 1;
all_images.removeClass('power').fadeOut('slow');
first.addClass('power').fadeIn('slow');
}
}, 2000);
});
它在所有其他浏览器中运行良好,除了在 Google Chrome 中它只触发一次。