Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

adding a timer in a quiz game

var sec = 15;
var time = setInterval(myTimer, 1000);

function myTimer() {
    document.getElementById('timer').innerHTML = sec + "sec left";
    sec--;
    if (sec == -1) {
        clearInterval(time);
        alert("Time out!! :(");
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #adding #timer #quiz #game
ADD COMMENT
Topic
Name
8+4 =