标签:
<!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