Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>&lt;span class="countdown" rel="30"&gt;0:30&lt;/span&gt;&lt;br/&gt; &lt;span class="countdown" rel="60"&gt;1:00&lt;/span&gt;&lt;br/&gt; &lt;span class="countdown" rel="1800"&gt;30:00&lt;/span&gt;&lt;br/&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; // Initialization $(document).ready(function(){ // Replace &lt;span class="countdown"&gt; rel content with the expiry epoch time var date = new Date(); // This gives you an epoch date in milliseconds $('span.countdown').each(function(){ // We do rel*1000 to convert to milliseconds, cause rel is in seconds $(this).attr('rel', date.getTime()+parseInt($(this).attr('rel'))*1000); }); // Set an interval so updateCountdown() is called every second setInterval('updateCountdown()', 1000); }); // Update, called every second function updateCountdown() { var date = new Date(); // This gives you an epoch date in milliseconds // For each &lt;span class="countdown"&gt; $('span.countdown').each(function(){ // Get time left in milliseconds var timeLeft = parseInt($(this).attr('rel')) - date.getTime(); // Convert from milliseconds to seconds timeLeft = Math.round(timeLeft/1000); // Set to 0 if negative if (timeLeft &lt; 0) timeLeft = 0; // Extract minutes and seconds for display var secs = timeLeft % 60; var mins = (timeLeft-secs)/60; // Change &lt;span&gt; content $(this).text(mins+':'+(secs&lt;10?'0':'')+secs); }); } &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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