-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
55 lines (42 loc) · 1.3 KB
/
main.js
File metadata and controls
55 lines (42 loc) · 1.3 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
44
45
46
47
48
49
50
51
52
53
54
55
let hour = 0;
let minute =0;
let second = 0;
let time = document.getElementById("time")
time.innerHTML = hour+":"+minute+":"+second
let startt = document.getElementById("start")
let stopp = document.getElementById("stop")
let resett = document.getElementById("reset")
var intervalID
function timer(){
second++;
time.innerHTML = hour+":"+minute+":"+second
if (second == 60){
minute++;
second = 0;
}else if(minute==60){
hour++;
minute = 0;
}
}
document.querySelector("#stop").disabled = true;
startt.onclick = function start(){
intervalID = setInterval(timer, 1000);
document.querySelector("#start").disabled = true;
document.querySelector("#stop").disabled = false;
}
stopp.onclick = function stop(){
clearInterval(intervalID);
startt.innerHTML = "Conitnue";
document.querySelector("#start").disabled = false;
document.querySelector("#stop").disabled = true;
}
resett.onclick = function reset(){
clearInterval(intervalID);
startt.innerHTML = "Start";
document.querySelector("#start").disabled = false;
document.querySelector("#stop").disabled = true;
hour = 0;
minute =0;
second = 0;
time.innerHTML = hour+":"+minute+":"+second;
}