我这里在setInterval里判断了timeNum如果等于0后我把定时器给设为null怎么还不行
$(".btncaptcha").click(function(){
var _this=this;
if(timeNum>0){
$(this).attr("disabled",true);
timeRun=setInterval(function(){
timeNum-=1;
_this.value="("+timeNum+")s重新获取";
if(timeNum==0){
timeRun=null;
_this.attr("disabled",false);
_this.value="重新获取";
}
},1000);
}
})
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
不要设置null,那是无效的,这样:
clearInterval(timeRun);
'''
清空计时器应该clearInterval