Javascript Code Countdown Timer On Online Quiz On Google Drive

Posted on

Javascript Code Countdown Timer On Online Quiz on Google Drive, you can use this code:

<b>Waktu Pengerjaan Soal:<b><span id=”time”>20:00</span></b> menit!</b>
<script type=’text/javascript’>
//<![CDATA[
function startTimer(duration, display) {
var timer = duration, minutes, seconds;
setInterval(function () {
minutes = parseInt(timer / 60, 10)
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? “0” + minutes : minutes;
seconds = seconds < 10 ? “0” + seconds : seconds;
display.textContent = minutes + “:” + seconds;
if (–timer < 0) {
timer = duration;
}
}, 1000);
}
window.onload = function () {
var fiveMinutes = 60 * 20,
display = document.querySelector(‘#time’);
startTimer(fiveMinutes, display);
};
//]]>
</script>