jquery控制按钮在几秒内不可用

 
function updateTimeLabel(time) {
    var btn = $("#btnLogin");
    btn.fadeIn(1000);
    btn.val(time <= 0 ? "提交" : ("" + (time) + "秒后可提交"));
    var hander = setInterval(function() {
        if (time <= 0) {
            canSubmit = true;
            hander = null;
            btn.val("提交");
            btn.css({ "cursor": "hand" }); //.attr("disabled",false);
        }
        else {
            canSubmit = false;
            btn.val("" + (time--) + "秒后可领取");
        }
    }, 1000);
}
updateTimeLabel(15);


你可能感兴趣的:(jquery,function,null)