title: How to start a timer for 10 minutes and than disable the button after the timer using javascript
body: <p><a href="https://i.stack.imgur.com/ixyVa.png" rel="nofollow noreferrer">The screenshot of the timer</a>
  I am working on a software and I want to disable the button after the timer gets finish. The timer have been added but cannot hide the button after the timer finishes.</p>
  
  <p>The following is the html of the timer.</p>
  
  <pre><code>                    &lt;div class="form-group"&gt;
                          &lt;label for="name" class="cols-sm-2 control-label"&gt;If you want to cancel the hiring you can &lt;br /&gt; Time remaining &lt;span id="time"&gt;&lt;/span&gt; minutes!    &lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group "&gt;
                          &lt;input type="submit" id="btnCancel" name="btnCancel" value="Cancel " class="btn btn-success btn-lg btn-block login-button" /&gt;
                      &lt;/div&gt;
  </code></pre>
  
  <p>The following is the javascript of the timer.</p>
  
  <pre><code>&lt;script&gt;
      function startTimer(duration, display) {
          var start = Date.now(),
              diff,
              minutes,
              seconds;
          function timer() {
              // get the number of seconds that have elapsed since
              // startTimer() was called
              diff = duration - (((Date.now() - start) / 1000) | 0);
  
              // does the same job as parseInt truncates the float
              minutes = (diff / 60) | 0;
              seconds = (diff % 60) | 0;
  
              minutes = minutes &lt; 10 ? "0" + minutes : minutes;
              seconds = seconds &lt; 10 ? "0" + seconds : seconds;
  
              display.textContent = minutes + ":" + seconds;
  
              if (diff &lt;= 0) {
                  // add one second so that the count down starts at the full duration
                  // example 05:00 not 04:59
                  start = Date.now() + 1000;
              }
          };
          // we don't want to wait a full second before the timer starts
          timer();
          setInterval(timer, 1000);
      }
  
      window.onload = function () {
          var tenMinutes = 60 * 10,
              display = document.querySelector('#time');
          startTimer(tenMinutes, display);
      };
  &lt;/script&gt;
  </code></pre>