Adding a timer to existing JS slider(向现有的 JS 滑块添加计时器)
问题描述
希望有人能指出我正确的方向.
我正在为客户建立一个在线商店并使用 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
这篇关于向现有的 JS 滑块添加计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:向现有的 JS 滑块添加计时器


- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01