当我点击那个向手机发送验证吗的按钮是(#sendsms),给那个按钮加了一个disabled属性,但是倒计时按钮还是可以点击,多次点击之后就出现问题,当curTime==0时,明明已经clearInterval(timer);了,但还是会不断进入if(curTime==0)里执行。$("#sendsms").on("click",function(){curTime=countTime;varphone=$("#form_phone").val();if(phone!=""){$("#sendsms").attr("disabled","true");$("#sendsms").text(curTime+"秒后可重新发送");timer=setInterval(handleTimer,1000);}});functionhandleTimer(){if(curTime==0){clearInterval(timer);timer=null;$("#sendsms").removeAttr("disabled");$("#sendsms").text("重新发送验证码");}else{curTime--;$("#sendsms").text(curTime+"秒后可重新发送");}}
眼眸繁星
沧海一幻觉
相关分类