首页 > 代码库 > 简单的计时器
简单的计时器
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE html><HTML lang="ch">
<HEAD>
<META charset="UTF-8">
<TITLE>计时器</TITLE>
<script src="http://www.mamicode.com/js/jquery-2.1.0.min.js"></script>
<SCRIPT type="text/javascript">
var c=0
var t
function timedCount()
{
document.getElementById(‘txt‘).value=http://www.mamicode.com/c
c=c+1
t=setTimeout("timedCount()",1000)
}
function stopCount()
{
c=0;
setTimeout("document.getElementById(‘txt‘).value=http://www.mamicode.com/0",0);
clearTimeout(t);
}
</SCRIPT>
<link rel="stylesheet" type="text/css" href="http://www.mamicode.com/css/wutong.css">
<META name="GENERATOR" content="MSHTML 9.00.8112.16421"></HEAD>
<BODY onl oad="init()">
<form>
<input type="button" value="http://www.mamicode.com/开始计时!" onClick="timedCount()">
<input type="text" id="txt">
<input type="button" value="http://www.mamicode.com/停止计时!" onClick="stopCount()">
</form>
</BODY>
</HTML>
简单的计时器