这可能以前已经得到了回答,我已经知道这应该如何工作,但出于某种原因,它不是。我想这可能是我在元素之间循环的方式。
$(document).ready(function() {
var element = #gallery ul#gallery-container ;
var idx=0;
var timeout = 3000;
var number = $(element + li ).length;
function changeSlide() {
$(element + li:eq( + idx + ) ).fadeOut();
idx = idx + 1;
if (idx == number) {
idx=0;
}
$(element + li:eq( + idx + ) ).fadeIn().delay(timeout).delay(0, function() {
changeSlide();
});;
}
$(element + li ).hide();
$(element + li:first ).fadeIn().delay(timeout).delay(0, function() {
changeSlide();
});
});
然后列表如下:
<div id="gallery">
<ul id="gallery-container">
<li><img src="media/images/screen-shot-02.jpg" width="173" height="258" alt=" "></li>
<li><img src="media/images/screen-shot-01.jpg" width="173" height="258" alt=" "></li>
</ul>
</div>
I was trying to get it to loop through the elements one by one, after a delay so the list item calls the function and hides itself, then the counter is incremented and then the current index is shown. I suspect the culprit to be this as if I put an alert in the function it is called:
$(element + li:eq( + idx + ) ).fadeOut();