ITPub博客

首页 > > > setInterval倒计时结束怎么停止

setInterval倒计时结束怎么停止

作者:limiao 时间:2019-08-19 15:22:01 0 删除 编辑
<html>
<head>
    <meta charset="utf-8">
</head>

<body>

<DIV id="CountMsg" class="HotDate">
    <span id="t_s">00秒</span>
</DIV>
<script type="text/javascript">
    var s=0
    function set_val(){
        s = document.getElementById("ttime").value;
    }
    function getRTime(){
        document.getElementById("t_s").innerHTML = s + "秒";
        s-=1
        if(s == 0){
            Window.clearInterval()
        }
    }
    setInterval(getRTime,1000);
</script>
</body>
<input type="text" id="ttime" value=10>
<button type="button" id="btn" onclick="set_val()">点我</button>
</html>

当s为0时怎么停止setInterval

我那句Window.clearInterval();好像没什么用

htmljavascript

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4549/viewspace-3151928/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-07-10

  • 博文量
    190
  • 访问量
    1371