按钮不可用读秒的JS方法

    function setDisabledTime(id, time) {
        var btn = $("#" + id);
        var originBtnValue = btn.val();
        btn.fadeIn(1000);
        btn.val(time <= 0 ? originBtnValue : ("" + (time) + "秒后可提交"));
        var hander = setInterval(function () {
            if (time <= 0) {
                clearInterval(hander);
                btn.val(originBtnValue);
                btn.removeAttr("disabled");
            } else {
                btn.attr({ "disabled": "disabled" });
                btn.val("" + (time--) + "秒后可提交");
            }
        }, 1000);
    };

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