clearInterval() 方法可取消由 setInterval() 设置的 timeout。

clearInterval() 方法的参数必须是由 setInterval() 返回的 ID 值。

 

setInterval()  =>clearInterval() =>setTimeout()

 

<!DOCTYPE html>
<html>
<head>
<script src="js/jquery-1.8.3.js">
</script>
<body>
<div id='show'></div><br />
<input type='button' value='stop' onclick='fun1()'/>
</body>
<script>
var getdata = setInterval(fun2,1000);
var showid = document.getElementById('show');
function fun1() {
    clearInterval(getdata);
    //showid.innerHTML = 'waiting 10s';
    setTimeout(fun3,10000);
}
function fun2() {
    showid.innerHTML += '1';
}
function fun3() {
    getdata  = setInterval(bb,1000);
}
</script>
</head>
 
</html>

 

相关文章:

  • 2022-02-17
  • 2021-08-23
  • 2021-07-25
  • 2022-12-23
  • 2021-07-15
  • 2021-08-13
  • 2021-08-04
  • 2021-07-03
猜你喜欢
  • 2022-12-23
  • 2021-10-04
  • 2022-01-12
  • 2021-07-11
  • 2021-10-16
  • 2021-08-24
  • 2021-05-20
相关资源
相似解决方案