-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (28 loc) · 924 Bytes
/
app.js
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
const timeEl=document.querySelector(".time")
const btnToggle=document.querySelector(".toggle")
function setTime(){
const time = new Date()
const hours = time.getHours()
const minutes = time.getMinutes()
const seconds = time.getSeconds()
timeEl.innerHTML=`${hours<10 ? `0${hours}`: hours}:
${minutes<10 ? `0${minutes}`: minutes}:
${seconds<10 ? `0${seconds}`: seconds}`
}
btnToggle.addEventListener("click",(e)=>{
const html=document.querySelector('html')
if(html.classList.contains("dark")){
html.classList.remove("dark")
e.target.innerHTML="Dark Mode"
}else{
html.classList.add("dark")
e.target.innerHTML="Light Mode"
}
})
setTime()
setInterval(setTime,1000)
const button = document.querySelector("#myButton");
const clickSound = document.querySelector("#clickSound");
button.addEventListener("click", function() {
clickSound.play();
});