美文网首页
发送验证码倒计时

发送验证码倒计时

作者: jiaomeichen | 来源:发表于2018-03-12 11:33 被阅读0次
使用方法:time($("input"))
/* 倒计时函数 */
var wait = 60,
    timer;
function time(o) {
    if(wait == 0) {
        o.removeAttr("disabled");
        o.css("backgroundColor", "rgba(34,211,162,1)");
        o.val("获取验证码");
        wait = 60;
    } else {
        o.attr("disabled", true);
        o.css("backgroundColor", "rgba(34,211,162,0.7)");
        o.val("重新获取(" + wait + "s)");
        wait--;
        timer = setTimeout(function() {
            time(o)
        }, 1000)
    }
}

相关文章

网友评论

      本文标题:发送验证码倒计时

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