jQuery 短信验证码倒计时
1 <script type="text/javascript" charset="utf-8"> 2 $(function(){ 3 //获取短信验证码 4 var validCode=true; 5 $(".T-getCode").click (function () { 6 var time=60; 7 var $code=$(this); 8 if (validCode) { 9 validCode=false; 10 var t=setInterval(function () { 11 time--; 12 $code.html(time+"秒"); 13 if (time==0) { 14 clearInterval(t); 15 $code.html("重新获取"); 16 validCode=true; 17 } 18 },1000) 19 } 20 }) 21 }) 22 </script>