js, jq Sending Short Message Countdown
Published: 2019-05-15

js:

< inputtype = "button" id = "btn" value = "get verification code for free"/>

<script type="text/ javascript">
var wait=60;
function time(o) {
        if (wait == 0) {
            o.removeAttribute("disabled");           
            o.value="免费获取验证码";
            wait = 60;
        } else { // www.jbxue.com
            o.setAttribute("disabled", true);
            o.value="重新发送(" + wait + ")";
            wait--;
            setTimeout(function() {
                time(o)
            },
            1000)
        }
    }
document.getElementById("btn").onclick=function(){time(this);}

</script>


jq: (JS's one is not very easy to use on my project and wrote a JQ by myself)

var step = 59;
$ ('# btn'). val ('resend 60');
var _res = setInterval(function()
bracket
$("#btn").attr("disabled", true);//Set disabled Property
$ ('# btn'). val ('resend' +step);
step-=1;
if(step <= 0){
$("#btn").removeAttr("disabled");//Remove disabled Attribute
$ ('# BTN'). Val ('Get Verification Code');
clearInterval(_res);//Clear setInterval
bracket
},1000);