但是,因为这样的事情可能涉及逻辑,所以我强烈建议使用第三方 jQuery 插件,例如 Nivo 滑块...
lets say you have functions next() and prev() to scroll the images with the buttons. if you want to autoscroll, based on what you've written above, you would use a timer via the setTimeout function like so:
window.setTimeout(next, 5000);
This would scroll to the next image every 5 seconds. Now, if you're at the end of the gallery, you could write some logic to determine that and go back to the beginning or go in the reverse order.
However, Because there can be a logic involved in something like this, I would highly recommend using a third-party jQuery plug-in such as Nivo Slider...
发布评论
评论(1)
假设您有函数
next()
和prev()
来使用按钮滚动图像。如果您想要自动滚动,根据您上面所写的内容,您可以通过setTimeout
函数使用计时器,如下所示:window.setTimeout(next, 5000);
这将每 5 秒滚动到下一张图像。现在,如果您位于画廊的末尾,您可以编写一些逻辑来确定这一点,然后返回到开头或按相反的顺序进行。
但是,因为这样的事情可能涉及逻辑,所以我强烈建议使用第三方 jQuery 插件,例如 Nivo 滑块...
lets say you have functions
next()
andprev()
to scroll the images with the buttons. if you want to autoscroll, based on what you've written above, you would use a timer via thesetTimeout
function like so:window.setTimeout(next, 5000);
This would scroll to the next image every 5 seconds. Now, if you're at the end of the gallery, you could write some logic to determine that and go back to the beginning or go in the reverse order.
However, Because there can be a logic involved in something like this, I would highly recommend using a third-party jQuery plug-in such as Nivo Slider...