js实现秒表

点击按钮开始计时

点击停止按钮暂停

下面是代码

<html>

<head>
<script type=”text/javascript”>
var c=0
var t

function timedCount()
{
document.getElementById(‘txt’).value=c
c=c+1
t=setTimeout(“timedCount()”,100)
}

function stopCount()
{
clearTimeout(t)
}
</script>
</head>

<body>
<form>
<input type=”button” value=”Start count!” onClick=”timedCount()”>
<input type=”text” id=”txt”>
<input type=”button” value=”Stop count!” onClick=”stopCount()”>
</form>
</body>

</html>