在jQuery中每5秒调用一个函数最简单的方法是什么? [英] What's the easiest way to call a function every 5 seconds in jQuery?
本文介绍了在jQuery中每5秒调用一个函数最简单的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
JQuery,如何每隔5秒调用一次函数。
JQuery, how to call a function every 5 seconds.
我正在寻找一种方法来自动更改幻灯片中的图像。
I'm looking for a way to automate the changing of images in a slideshow.
如果可能,我宁愿不安装任何其他第三方插件。
I'd rather not install any other 3rd party plugins if possible.
推荐答案
你不需要jquery,在普通的javascript中,以下内容可行!
You don't need jquery for this, in plain javascript, the following will work!
window.setInterval(function(){
/// call your function here
}, 5000);
要停止循环,您可以使用
To stop the loop you can use
clearInterval()
这篇关于在jQuery中每5秒调用一个函数最简单的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文