forked from codemistic/Web-Development
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
42 lines (28 loc) · 1.56 KB
/
main.js
File metadata and controls
42 lines (28 loc) · 1.56 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
const secondhand=document.querySelector('.secondhand');
const minutehand=document.querySelector('.hourhand');
const audio = document.querySelector('.audio');
function setdate() {
const now = new Date();
const seconds = now.getSeconds();
const a = (seconds*6);
console.log(a);
secondhand.style.transform = `rotate(${a}deg)`;
audio.play();
audio.currentTime = 1;
//using properties that have : , :is replaced by = and than the ahead part comes in backticks
//whenever you are writing a varible const use ${} and whenever you use ${} you must use `` backtics (i.e esc down button) to close your brackets
// how to change the class of an elemt by js , make that new class in css and use elementconstname.classList.add('newstyleclassname');
}
function setminute() {
const now = new Date();
const minutes = now.getMinutes();
const m = ((minutes*6)-90);
console.log(m);
minutehand.style.transform = `rotate(${m}deg)`;
//using properties that have : , :is replaced by = and than the ahead part comes in backticks
//whenever you are writing a varible const use ${} and whenever you use ${} you must use `` backtics (i.e esc down button) to close your brackets
// how to change the class of an elemt by js , make that new class in css and use elementconstname.classList.add('newstyleclassname');
}
setInterval(setdate,1000);
setInterval(setminute,1000);
//syntax for setinterval is setInterval(functionname, milli seconds after which you want to reoperate the function )