为什么clearTimeout不能自动停止
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<script type="text/javascript">
var c=0;
var t;
function timedCount()
{
if(c>=20){stopCount();};
document.getElementById('txt').value=c;
c++;
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>
点击按钮的时候就可以停止 但是用if来判断c>20的时候就不能停止,哪里错了?