我制作了一个由三张图片组成的幻灯片。我现在想重复完全相同的内容,但使用不同的图片。image3.jpg、image4.jpg 和 image5.jpg。
任何人都可以帮忙吗?
HTML 是:
<div id="slideshow">
<div id="slideshowWindow">
<div class="slide">
<img src="images/slide1.jpg" />
</div><!--/slide-->
<div class="slide">
<img src="images/slide2.jpg" />
</div><!--/slide-->
<div class="slide">
<img src="images/slide3.jpg" />
</div><!--/slide-->
</div><!--/slideshowWindow-->
</div><!--/slideshow-->
CSS是:
#slideshow {
position:relative;
top:10px;
left:80px;
margin-bottom:400px;
}
#slideshow #slideshowWindow {
width:500px;
height:95px;
margin:0;
padding:0;
position:relative;
overflow:hidden;
}
#slideshow #slideshowWindow .slide {
margin:0;
padding:0;
width:500px;
height:95px;
float:left;
position:relative;
}
jQuery是:
$(document).ready(function() {
var currentPosition = 0;
var slideWidth = 500;
var slides = $('.slide');
var numberOfSlides = slides.length;
var slideShowInterval;
var speed = 10000;
slideShowInterval = setInterval(changePosition, speed);
slides.wrapAll('<div id="slidesHolder"></div>')
slides.css({ 'float' : 'left' });
$('#slidesHolder').css('width', slideWidth * numberOfSlides);
function changePosition() {
if(currentPosition == numberOfSlides - 1) {
currentPosition = 0;
} else {
currentPosition++;
}
moveSlide();
}
function moveSlide() {
$('#slidesHolder')
.animate({'marginLeft' : slideWidth*(-currentPosition)});
}
});