Adding a timer to existing JS slider

徘徊边缘 提交于 2019-12-12 04:34:15

问题


Hoping someone can point me in the right direction.
I'm building a online shop for a client and am using the PrestaShop Moon theme (link). You'll notice in the demo that there is a slider. However, the slider doesn't change automatically every few seconds like some sliders out there (for example this one). The Moon theme uses an old slider created by Brian Reindel which is no longer supported.

The themes slider also calls boot.js which only includes.

$(function() {

    $( "#slides" ).accessNews({
        speed : "normal",
        slideBy : 1
    });


});

So my question is taking the existing .js can it be modified to auto-slide?

Thank you everyone for your help!


回答1:


Yes, just set an interval and invoke the "click" event on the arrow that scrolls. It should look something like the following:


function makeScroll() {
 $('#arrow').click();
}

setInterval(makeScroll, secs*1000);

where secs is the num of secs you want delayed



来源:https://stackoverflow.com/questions/2418453/adding-a-timer-to-existing-js-slider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!