如何启动计时器10分钟,然后使用javascript在计时器后禁用按钮

时间:2017-03-12 12:37:41

标签: javascript button timer countdowntimer

The screenshot of the timer 我正在研究一个软件,我希望在计时器完成后禁用该按钮。计时器已经添加,但计时器结束后无法隐藏按钮。

以下是计时器的html。

class AutoLogout(object):
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):

        if not request.user.is_authenticated():
            # Can't log out if not logged in
            return None

        if datetime.now() - request.session['last_touch'] > timedelta( 0, settings.AUTO_LOGOUT_DELAY * 60, 0):
            try:
                auth.logout(request)
                del request.session['last_touch']
            except KeyError:
                pass
            else:
                request.session['last_touch'] = datetime.now()
        return self.get_response(request)

以下是计时器的javascript。

                    <div class="form-group">
                        <label for="name" class="cols-sm-2 control-label">If you want to cancel the hiring you can <br /> Time remaining <span id="time"></span> minutes!    </label>
                    </div>
                    <div class="form-group ">
                        <input type="submit" id="btnCancel" name="btnCancel" value="Cancel " class="btn btn-success btn-lg btn-block login-button" />
                    </div>

1 个答案:

答案 0 :(得分:0)

setTimeout(function(){
   document.getElementById("disablethis").disabled  = true;
}, 1000 * 60 * 10);