$(function(){
	getMsg(); //页面加载完成之后执行
})
 function getMsg(){
                //注册按钮的点击事件
		$("#smsBtn").on("click", function(){ 
			 $("#smsBtn").off(); //解除绑定,防止重复点击
			 
			 //dosomething
			 //1.校验
			 if(checkValue()){ 
				 getMsg(); //重新注册
		    	         return false;
		        } 
			 //2.发送验证码
			 sendMsg();
			  var _this=$(this);
			 var i = 10;
                    //定义计时器
                   var timer = setInterval(function () {  
                 _this.val(i);
                 i--; 
                 if (i < 0) {
                     clearInterval(timer);  //清除计时器
                     _this.val('获取验证码');
                     getMsg();
                 }
             }, 1000);
		})
	}

  

相关文章:

  • 2022-01-29
  • 2022-12-23
  • 2021-12-04
  • 2021-09-10
  • 2022-12-23
  • 2021-11-03
  • 2021-12-03
猜你喜欢
  • 2021-11-25
  • 2021-07-09
  • 2021-11-23
  • 2021-12-04
  • 2021-11-23
  • 2021-10-13
相关资源
相似解决方案