<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style type="text/css">
    #btn1:hover,#btn2:hover {
        background: red;
    }
</style>
</head>

<body>
<input type="button" id="btn1" value="开启" />
<input type="button" id="btn2" value="关闭" />
<script>
    var obtn1=document.getElementById('btn1');
    var obtn2=document.getElementById('btn2');
    var timer=null;
    obtn1.onclick=function()
    {
        timer=setInterval(function()   //开启循环:每秒出现一次提示框
        {
            alert('a');
        },1000);
    }
    obtn2.onclick=function()
    {
        clearInterval(timer);        //关闭循环
    }
</script>
</body>
</html>

相关文章:

  • 2021-12-24
  • 2021-10-29
  • 2022-12-23
  • 2021-05-10
  • 2021-11-18
  • 2021-06-07
猜你喜欢
  • 2021-11-30
  • 2021-10-25
  • 2021-11-30
  • 2021-04-23
  • 2022-01-26
相关资源
相似解决方案