我不知道出了什么问题(有问题的行有多个星号)这是幻灯片。在 JS 部分,DW 一直告诉我在包含 rotatePics 函数的行上有错误。
这是 HTML 部分:
<div id=photos>
<img src="../imgs/dr_gonzalez.jpg" class=show alt="Dr. G">
<img src="../imgs/immunization.jpg" alt="SHOTZ!">
<img src="../imgs/senior_pet.jpg" alt="Former Puppies">
<img src="../imgs/vet_barnes.jpg" alt="Best doctor ever">
</div>
CSS部分:
#photos img {position:absolute;
}
#photos{
width: 241px;
height: 329px;
overflow:hidden;
}
aaaaannnnnnddd JS,这是我需要调试的:
$(document).ready(function() {
slideShow();
});
function slideShow() {
var current = $('#photos .show');
var next = current.next().length ? current.next() :
current.siblings().first;
current.hide().removeClass('show');
next.fadeIn().addClass('show');
setTimeout(slideShow, 3000);
}
$(document).ready(function() {
rotatePics(1);
}
***function rotatePics(currentPhoto){***
var numberOfPhotos = $('#photos img').length;
currentPhoto = currentPhoto % numberOfPhotos;
$('#photos img').eq(currentPhoto).fadeOut(function (){
$('#photos img').each(function (i)
{
$(this).css('zIndex', ((numberOfPhotos - i) +currentPhoto) numberOfPhotos);
});
$(this).show();
setTimeout(function ()
{
rotatePics(++currentPhoto);
}, 4000);
});
};