-
Notifications
You must be signed in to change notification settings - Fork 1
/
darkMode.js
25 lines (24 loc) · 904 Bytes
/
darkMode.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
function toggleDarkMode() {
let curr = document.querySelector(".wrapper");
let cat = document.querySelectorAll(".category");
let db = document.querySelector(".darkBtn");
if(curr.classList.contains("darkModeClass")) {
db.innerText = "Dark Mode";
db.classList.remove("darkModeClass");
curr.classList.remove("darkModeClass");
for(let i = 0; i < cat.length; i++) {
cat[i].classList.remove("darkModeClass");
cat[i].classList.remove("darkModeClassShadow");
}
}
else {
db.innerText = "Light Mode";
db.classList.add("darkModeClass");
db.classList.add("darkModeClassShadow");
curr.classList.add("darkModeClass");
for(let i = 0; i < cat.length; i++) {
cat[i].classList.add("darkModeClass");
cat[i].classList.add("darkModeClassShadow");
}
}
}