美文网首页
js简单实现发送验证码后的倒计时效果

js简单实现发送验证码后的倒计时效果

作者: 铁匠简记 | 来源:发表于2018-06-24 21:49 被阅读3次

简简单单

<javascript>
var time = 60;
function send(_this){
    var phone = "";
    // 发送短信业务代码--略
    if (time == 0) {
        _this.removeAttribute("disabed");
        _this.value = "发送短信";
        time = 60;
        time--;
        return;
    }else{
        _this.setAttribute('disabed',true);
        _this.value = "重新发送(" + time + "s)";
        time--;
    }
    // 定时器
    setTimeout(function(){
        send(_this);
    },1000);
}
</javascript>

相关文章

网友评论

      本文标题:js简单实现发送验证码后的倒计时效果

      本文链接:https://www.haomeiwen.com/subject/jawsyftx.html