发送验证码倒计时

2018-03-12  本文已影响0人  jiaomeichen
使用方法: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)
    }
}
上一篇 下一篇

猜你喜欢

热点阅读