Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you can accept lightweight code, i.e. without using the jQuery countdown timer, the following might help you:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;script type="text/javascript" src="http://localhost/web/JavaScript/jQuery/jquery"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var countUpSeconds = 0; var interval = null; function displayTime() { $("#timeContainer").text(format(Math.floor(countUpSeconds/60))+":"+format(countUpSeconds%60)); } function playStop() { if(interval) {interval=window.clearInterval(interval);} else {interval = window.setInterval(countUp, 1000);} } function countUp() { ++countUpSeconds; if(countUpSeconds &gt;= 3600) {/* do something when countup is reached*/} displayTime(); } function format(s) {return s&lt;10 ? "0"+s : s;} $(function() { displayTime(); $("#playStop").on("click", function () { playStop(); } ); $("#addMin").on("click", function () { countUpSeconds += 60; displayTime(); } ); $("#subMin").on("click", function () { countUpSeconds = Math.max(0, countUpSeconds-60); displayTime(); } ); $("#addSec").on("click", function () { countUpSeconds += 1; displayTime(); } ); $("#subSec").on("click", function () { countUpSeconds = Math.max(0, countUpSeconds-1); displayTime(); } ); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="timeContainer"&gt;&lt;/div&gt; &lt;button id="playStop"&gt;Play/Stop&lt;/button&gt; &lt;button id="addMin"&gt;+1 minute&lt;/button&gt; &lt;button id="subMin"&gt;-1 minute&lt;/button&gt; &lt;button id="addSec"&gt;+1 second&lt;/button&gt; &lt;button id="subSec"&gt;-1 second&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload