瞄一眼这些Js函数setTimeOut setInterval clearTimeOut,蒙了。为什么呢?

 

当然是概念混淆了!刚查了一下,做个纪念先:

setInterval("js code",time):每隔time时间执行一次其所指定的js Code。

setTimeOut("jscode",time):time之后执行一次....【仅仅执行一次】

clearTimeOut("settimeout的引用"):清除setTimeOut计时器。

 

 1 <html>
 2 <head></head>
 3 <body>
 4 <div id="intime"></div>
 5 <div id="timeouttime"></div>
 6 <script type="text/javascript">
 7 function showtime(ele){
 8     timer=new Date();
 9     document.getElementById(ele).innerHTML=timer.getHours()+":"+timer.getMinutes()+":"+timer.getSeconds();
10 }
11 setTimeout("showtime('timeouttime')",1000);
12 setInterval("showtime('intime')",1000);
13 </script>
14 </body>
15 </html>

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
  • 2021-07-09
  • 2021-11-13
  • 2022-12-23
  • 2021-06-28
猜你喜欢
  • 2021-10-12
  • 2021-08-24
  • 2021-07-03
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案