首页 > 其他 > 详细

计时器

时间:2015-12-03 00:34:23      阅读:350      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>定时器</title>
</head>
<body>
<input type="button" value="开始计时!" onclick="timedCount()" />
<input type="text" id="txt" />
<input type="button" value="停止" onclick="stopCount()"/>
<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(){
clearTimeout(t);
}
</script>
</body>
</html>

计时器

原文:http://www.cnblogs.com/yifeizeng168/p/5014444.html

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