Welcome aboard! We are happy you are here and wish you good net-raft!
<html>
<head>
<title></title>
<meta charset="utf-8">
<script type="text/javascript">
var sec = 0;
function pad(val) { return val > 9 ? val : "0" + val; }
var func;
function timerstart() {
func = setInterval(function () {
document.getElementById("seconds").innerHTML = pad(++sec % 60);
document.getElementById("minutes").innerHTML = pad(parseInt(sec / 60, 10));
}, 1000);
}
timerstart();
function myStopFunction() {
clearInterval(func);
}
function myClearFunction() {
myStopFunction();
document.getElementById("seconds").innerHTML = pad(00);
document.getElementById("minutes").innerHTML = pad(00);
sec = 0;
}
</script>
</head>
<body>
<div class="quiz-time">
<div class="timer">
<span id="minutes">00</span>:<span id="seconds">00</span>
</div>
<button onclick="myStopFunction()">Stop</button>
<button onclick="timerstart()">Start Again</button>
<button onclick="myClearFunction();">Clear</button>
</div>
</body>
</html>
The most helpful JAVASCRIPT solutions
How can I get the last day and the next day in javascript ?JAVASCRIPT Click to see more ... 5.8K 507