码迷,mamicode.com
首页 > 其他好文 > 详细

计时器

时间:2015-01-09 12:31:21      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

<p id="demo"></p>
<button onclick="myStopFunction()">Stop time</button>

<script>
var myVar=setInterval(function(){myTimer()},1000);
function myTimer()
{
var d=new Date();
var t=d.toLocaleTimeString();
document.getElementById("demo").innerHTML=t;
}
function myStopFunction()
{
clearInterval(myVar);
}
</script>

 

计时器

标签:

原文地址:http://www.cnblogs.com/hanbingljw/p/3977648.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!