<!DOCTYPE html >
<html>
<head>
<title> new document </title>
<meta charset="utf-8"/>
<script type="text/javascript">
var timer=0;
function stime()
{
document.getElementById("txt").value=timer;
timer=timer+1;
var i=setTimeout(stime,1000)
}
function otime()
{
clearTimeout(i);
}
</script>
</head>
<body>
<form>
<input type="text" id="txt" >
<input type="button" value="开始计时" onclick="stime()">
<input type="button" value="计时结束" onclick="otime()">
</form>
</body>
</html>
李晓健
淡雅的默
相关分类