jquery autoplay函数只能工作一次

时间:2014-05-08 11:00:43

标签: javascript jquery

我从此页http://jquery.lemmonjuice.com/plugins/slider-variable-widths.php复制了此代码,但在我的页面上,自动播放功能只能运行一次。 你能救我吗?

var sliderTimeout;
window.onload = function(){
// initialize slider
$( '#slider1' ).lemmonSlider({

    'slideToLast' : true

});
// run
sliderAutoplay();
}
// slider autoplay function
function sliderAutoplay(){

$( '#slider1' ).trigger( 'nextSlide' );
sliderTimeout = setTimeout( 'sliderAutoplay', 3000 );

}

2 个答案:

答案 0 :(得分:1)

删除setTimeout函数函数的单引号,第一个参数是函数而不是字符串。

sliderTimeout = setTimeout(sliderAutoplay, 3000 );

答案 1 :(得分:1)

setInterval(function(){ sliderAutoplay() },3000); 

试试这个