-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.js
More file actions
25 lines (24 loc) · 741 Bytes
/
clock.js
File metadata and controls
25 lines (24 loc) · 741 Bytes
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
let sec = document.getElementById('sec');
let min = document.getElementById('min');
let hr = document.getElementById('hr');
const deg = 6;
let body=document.querySelector('body')
let mode=document.getElementById('mode')
let cls=body.classList
mode.addEventListener('click',()=>{
if(cls =='light'){
body.classList.remove('light');
}
else{
body.classList.add('light');
}
})
setInterval(() => {
let day = new Date();
let hh = day.getHours() * 30;
let mm = day.getMinutes() * 6;
let ss = day.getSeconds() * 6;
sec.style.transform = `rotateZ(${ss}deg)`;
min.style.transform = `rotateZ(${mm}deg)`;
hr.style.transform = `rotateZ(${hh}deg)`;
}, 1000);