I have created a countdown clock that will be counting down from 100 (looping each second).
This is the code:
<script>
$(document).ready(function(){
$("#buttonClick").on('click', function(){
var initialValue = $("#countdown").text();
setInterval(function () {
initialValue--;
$("#countdown").text(initialValue);
}, 1000);
});
});
</script>
<body>
<button id="buttonClick">Click Me</button>
<div id="countdown">100</div>
</body>
When i click the "Click Me" button the number counts down from 100, 99, 98,97....
When try this from a mobile device and while the device is awake, it works just fine.
Lets say the counter is on 50 and i press the power button of the mobile device and it sleeps.
If i wake the mobile after 40 seconds, i will not see the remaining 10 seconds but something like 40 or 38 seconds.
This happens every time and i don't know why.
Can someone help?
Regards,
Christos