js 计时器

<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>
</body>
</html>

posted @ 2015-02-11 11:40  Struts-pring  阅读(203)  评论(0编辑  收藏  举报