如何在显示最后一张照片后重置幻灯片

时间:2014-04-26 19:47:03

标签: jquery css slideshow

这是我的css文件。 如何在显示最后一张照片后重置幻灯片

function slideSwitch() {
    var $active = $('div#slideshow IMG.active');
    var $next = $active.next();   

    $next.addClass('active');
    $active.removeClass('active');
}

$(function() {
    setInterval( "slideSwitch()", 5000); 
    $('#slideSwitch()').slider('div#slideshow', 0);
});

这是我的HTML

<div id="slideshow">
    <img src="img/1.jpg" width="400" height="200" border="6" style="width:400px; margin-left:-200px; left:50%; position:absolute; border-color:#B30000;" class="active" />
    <img src="img/2.jpg" width="400" height="200" border="6" style="width:400px; margin-left:-200px; left:50%; position:absolute; border-color:#B30000;" />
    <img src="img/3.jpg" width="400" height="200" border="6" style="width:400px; margin-left:-200px; left:50%; position:absolute; border-color:#B30000;" />
</div>

提前致谢!

1 个答案:

答案 0 :(得分:0)

而不是

var $next = $active.next();

尝试

var $next = ($active.next().length) ? $active.next() : $('#slideshow img:first);