我有一點javascript/jQuery創建一個簡單的幻燈片。我正在學習jquery,因爲我去了這裏......並且我很難理解如何在停止之前修改這個JS循環x次。現在,它在無限循環上播放幻燈片。有什麼建議麼?謝謝!簡單的幻燈片jQuery,需要它5張幻燈片後結束。幫幫我?
<script>
function slideSwitch() {
var $active = $('#slideshow DIV.active');
if ($active.length == 0) $active = $('#slideshow DIV.item:last');
var $next = $active.next().length ? $active.next()
: $('#slideshow DIV.item:first');
$active.addClass('last-active');
$next.css({opacity: 0.0})
.addClass('active')
.animate({opacity: 1.0}, 1000, function() {
$active.removeClass('active last-active');
});
}
$(function() {
setInterval("slideSwitch()", 5000);
});
</script>
完美,這工作完美。非常感謝你! –