首页 > 其他 > 详细

计时器使用

时间:2015-03-03 15:03:32      阅读:131      评论:0      收藏:0      [点我收藏+]

<html>
<head>
<script type="text/javascript">
var c=0
var t
function timedCount()
{
document.getElementById(‘txt‘).value=c
c=c+1
t=setTimeout("timedCount()",1000)
}

function stopCount()
{
c=0;
setTimeout("document.getElementById(‘txt‘).value=0",0);
clearTimeout(t);
}
</script>
</head>

<body>

<form>
<input type="button" value="开始计时!" onClick="timedCount()">
<input type="text" id="txt">
<input type="button" value="停止计时!" onClick="stopCount()">
</form>

<p>请点击上面的“开始计时”按钮来启动计时器。输入框会一直进行计时,从 0 开始。点击“停止计时”按钮可以终止计时,并将计数重置为 0。</p>

</body>

</html>

计时器使用

原文:http://www.cnblogs.com/ftrako/p/4310837.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!