clearTimeout

<body>
<input type="text" name="display">
<input type="button" value="stop" onclick="stop()">
</body>
<script language="javascript">
var timeout1 = null;
function displayFresh()
{
  var aaa = Math.random();
  display.value = aaa;
  timeout1 = setTimeout("displayFresh()", 1000);
}

function stop()
{
  clearTimeout(timeout1);
}
displayFresh();
</script> 



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1302525

原文地址:https://www.cnblogs.com/Godblessyou/p/1779190.html