标签:
<html>
<head>
<script type="text/javascript">
var count=0;
var t ;
function timedText()
{
document.getElementById(‘txt‘).value = parseInt(count/60)+‘:‘+count%60;
count= count+1;
t = setTimeout("timedText()",1000);
}
function stop(){
clearTimeout(t);
}
</script>
</head>
<body>
<form>
<input type="button" value="开始计时" onClick="timedText()">
<input type="text" id="txt">
<input type="button" value="停止计时" onClick="stop()">
</form>
<p>在按钮上面点击。输入框会显示出已经流逝的 2、4、6 秒钟。</p>
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/Struts-pring/p/4285737.html