连续每5秒调用一次javascript函数 [英] Call a javascript function every 5 seconds continuously

查看:152
本文介绍了连续每5秒调用一次javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

每60秒调用一次功能

呼叫a javascript函数每5秒连续一次。
我见过setTimeOut事件。如果我想继续它会工作正常吗?

call a javascript function every 5 seconds continuously. I have seen the setTimeOut event. will it be working fine if i want it continuously?

推荐答案

你可以使用 setInterval() ,参数相同。

You can use setInterval(), the arguments are the same.

setInterval(function() {
  // method to be executed;
}, 5000);

这篇关于连续每5秒调用一次javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆