向现有的 JS 滑块添加计时器

2022-01-24 00:00:00 timer slider javascript

希望有人能指出我正确的方向.
我正在为客户建立一个在线商店并使用 PrestaShop Moon 主题 (链接).您会在演示中注意到有一个滑块.但是,滑块不会像其他一些滑块那样每隔几秒自动更改一次(例如这个 one).Moon 主题使用由 Brian Reindel 创建的旧滑块,不再受支持.

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.

主题滑块也调用 boot.js,其中只包含.

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

$(function() {

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


});

所以我的问题是采用现有的 .js 是否可以修改为自动滑动?

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

感谢大家的帮助!

推荐答案

是的,只需设置一个间隔并在滚动的箭头上调用click"事件.它应该如下所示:

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);

其中 secs 是您想要延迟的秒数

where secs is the num of secs you want delayed

相关文章