javascript 如何让jquery自动播放?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12347401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 15:59:32  来源:igfitidea点击:

How to make the jquery play automatically?

javascriptjquerysliderautoplay

提问by Christopher Leandro Kwok

I have a question about my slideshow, i want it to play automatically, how to do it???

我有一个关于我的幻灯片的问题,我想让它自动播放,怎么做???

i've already changed the autoplay setting from false to true, but still cant.

我已经将自动播放设置从 false 更改为 true,但仍然不能。

here is my code:

这是我的代码:

 <script>
  jQuery(document).ready(function($) {
  $('#full-width-slider').royalSlider({
    arrowsNav: true,
    loop: true,
    keyboardNavEnabled: true,
    controlsInside: false,
    imageScaleMode: 'fill',
    arrowsNavAutoHide: false,
    autoScaleSlider: true, 
    autoScaleSliderWidth: 960,     
    autoScaleSliderHeight: 350,
    controlNavigation: 'bullets',
    thumbsFitInViewport: false,
    navigateByClick: true,
    startSlideId: 0,
    autoPlay: true,
    transitionType:'move',
    globalCaption: true
  });
});

</script>

and here is my link if you need to read the jquery file

如果您需要阅读 jquery 文件,这是我的链接

My Slider problem link

我的滑块问题链接

THANKS

谢谢

回答by

Try this,

试试这个,

autoPlay: {
   enabled: true,
   delay: 1500
}

Change the delay according to your requirement.

根据您的要求更改延迟。

Or just try,

或者只是尝试,

autoPlay : {
     enabled : true
}

回答by Sebastian.Belczyk

AutoPlay property requires an object not true\flase value, look at doc

AutoPlay 属性需要一个不是 true\flase value 的对象,请看文档

Try this code:

试试这个代码:

 <script>
  jQuery(document).ready(function($) {
  $('#full-width-slider').royalSlider({
    arrowsNav: true,
    loop: true,
    keyboardNavEnabled: true,
    controlsInside: false,
    imageScaleMode: 'fill',
    arrowsNavAutoHide: false,
    autoScaleSlider: true, 
    autoScaleSliderWidth: 960,     
    autoScaleSliderHeight: 350,
    controlNavigation: 'bullets',
    thumbsFitInViewport: false,
    navigateByClick: true,
    startSlideId: 0,
    autoPlay:  {
            // autoplay options go gere
                enabled: true,
            pauseOnHover: true
               }
  });
});

Edit: "}" was missing after " pauseOnHover: true" .

编辑: "}" 在 " pauseOnHover: true" 之后丢失。