单击倒计时

 

<div class="getCodeWrap">
  <input class="iptClass wid310" type="text" value="" />
  <input class="getCode" type="button" value="获取验证码">
  <div class="codeTime"><span>60</span>s</div>
  <div class="error"><i class="errorIcon"></i>短信验证码有误,请重新输入!</div>
</div>

 

 

//单击倒计时
$(".getCode").click(function(){
$(this).hide();
$(this).next(".codeTime").show();

var ma=$(this);
function run(){
var s=ma.next().find('span').text();
if (s>0) {
ma.next().find('span').text(s-1);
} else{
clearInterval(m);
ma.show();
ma.next(".codeTime").hide();
$(".codeTime span").text("60")
}
}

var m=window.setInterval(run,1000);
})

posted @ 2018-09-25 11:30  南夏啊南夏  阅读(114)  评论(0编辑  收藏  举报