-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
43 lines (39 loc) · 1.16 KB
/
script.js
File metadata and controls
43 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var secondsvalue = 0,
minutesvalue = 0;
var clockId;
/* Clock Function*/
function clockfunction() {
var svalue = document.getElementById("seconds").innerHTML;
if (svalue == 59) {
secondsvalue = 0;
minutesvalue++;
}
document.getElementById("seconds").innerHTML = secondsvalue;
secondsvalue++;
document.getElementById("minute").innerHTML = minutesvalue;
}
/* Reset button*/
function resetfunction() {
clearInterval(clockId);
document.getElementById("seconds").innerHTML = "00";
document.getElementById("minute").innerHTML = "00";
}
/* stop button*/
function stopfunction() {
clearInterval(clockId);
document.getElementById("seconds").innerHTML = secondsvalue;
document.getElementById("minute").innerHTML = minutesvalue;
}
/* start button */
function startfunction() {
var secondstext = document.getElementById("seconds").innerHTML;
var minutestext = document.getElementById("minute").innerHTML;
if (secondstext == 0) {
secondsvalue = 0;
}
if (secondstext == 00 && minutestext == 00) {
secondsvalue = 0;
minutesvalue = 0;
}
clockId = setInterval(clockfunction, 1000);
}