一、定时(setInterval)

var i = 0;  
function hello(){
    console.log(i++);
} 
setInterval(hello,1000); // 每一秒执行一次hello函数

二、延时(setTimeout)

var i = 0;  
function hello(){
    console.log(i++);
} 
setTimeout(hello,1000); // 一秒后执行hello函数(只执行一次)

 

相关文章:

  • 2021-08-09
  • 2022-12-23
  • 2021-10-03
  • 2021-06-26
  • 2022-01-22
  • 2022-12-23
  • 2021-11-05
猜你喜欢
  • 2022-01-11
  • 2021-08-08
  • 2022-01-05
  • 2022-12-23
  • 2021-10-04
  • 2021-08-10
  • 2021-07-01
相关资源
相似解决方案