<script>
$(document).ready(function(){
var timer2 = "05 : 01";
var interval = setInterval(function() {
var timer = timer2.split(':');
//by parsing integer, I avoid all extra string processing
var minutes = parseInt(timer[0], 10);
var seconds = parseInt(timer[1], 10);
--seconds;
minutes = (seconds < 0) ? --minutes : minutes;
if (minutes < 0) clearInterval(interval);
seconds = (seconds < 0) ? 59 : seconds;
seconds = (seconds < 10) ? '0' + seconds : seconds;
//minutes = (minutes < 10) ? minutes : minutes;
if(minutes == 0 && seconds == 0) {
console.log(minutes + " "+ seconds);
clearInterval(interval);
localStorage.removeItem('timerstart');
}
$('#timerSec').html(minutes + ' : ' + seconds);
timer2 = minutes + ' : ' + seconds;
}, 1000);
})
</script>
<strong id="timerSec" class="bold-text">05 : 00</strong>
No comments:
Post a Comment