Javascript:在特定时间段后调用函数 [英] Javascript: Call a function after specific time period

查看:100
本文介绍了Javascript:在特定时间段后调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaScript中,如何在特定时间间隔后调用函数?



这是我想要运行的函数:

  function FetchData(){
}


JavaScript时间事件

a>在特定时间间隔后调用函数:

这显示3秒钟后的提示框:

 的setInterval(函数(){警报( 你好)},3000); 

您可以在javascript.ie中使用两种时间事件方法


  1. setInterval():以
    指定的时间间隔重复执行一个函数

  2. setTimeout():在等待
    指定的毫秒数后执行一次函数


In JavaScript, How can I call a function after a specific time interval?

Here is my function I want to run:

function FetchData() {
}

解决方案

You can use JavaScript Timing Events to call function after certain interval of time:

This shows the alert box after 3 seconds:

setInterval(function(){alert("Hello")},3000);

You can use two method of time event in javascript.i.e.

  1. setInterval(): executes a function, over and over again, at specified time intervals
  2. setTimeout() : executes a function, once, after waiting a specified number of milliseconds

这篇关于Javascript:在特定时间段后调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆