我是 jQuery 的新手,我正在尝试创建幻灯片。我创建了它,但是当计时器更改我的图片时,所有页面似乎都被刷新了。
HTML 示例:
<div class="slide">
<img id="scroll_image" src="img/rooms/suite5.jpg" width="1000" height="350" alt="hotel-suite-1" class="show" />
<img id="scroll_image" src="img/rooms/suite1.jpg" width="1000" height="350" alt="hotel-suite-2" />
<img id="scroll_image" src="img/rooms/suite2.jpg" width="1000" height="350" alt="hotel-suite-3" />
<img id="scroll_image" src="img/rooms/suite3.jpg" width="1000" height="350" alt="hotel-suite-4" />
<img id="scroll_image" src="img/rooms/suite4.jpg" width="1000" height="350" alt="hotel-suite-5" />
</div><!--end of slide-->
jQuery 示例:
$(document).ready(function() {
slideShow();
});
function slideShow() {
var current = $('.slide .show');
var next = current.next().length ? current.next() : current.parent().children(':first');
current.hide().removeClass('show');
next.fadeIn().addClass('show');
setTimeout(slideShow, 6000);
}
如果您单击此处,向下滚动页面并等待计时器更改图像,您会明白我的意思!?