[英]jquery autoplay function works only once
I copyed this code from this page http://jquery.lemmonjuice.com/plugins/slider-variable-widths.php but on my page the autoplay function works only once. 我从这个页面http://jquery.lemmonjuice.com/plugins/slider-variable-widths.php复制了这段代码,但在我的页面上,自动播放功能只能工作一次。 Can you help me?
你能帮助我吗?
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 );
}
删除setTimeout函数函数的单引号,第一个参数是函数而不是字符串。
sliderTimeout = setTimeout(sliderAutoplay, 3000 );
setInterval(function(){ sliderAutoplay() },3000);
尝试这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.