首页 > > > setInterval倒计时结束怎么停止
<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/ ,如需转载,请注明出处,否则将追究法律责任。