-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
21 lines (19 loc) · 792 Bytes
/
main.js
File metadata and controls
21 lines (19 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const theme = document.getElementById("mode")
const sun = document.getElementById('mode_sun')
const moon = document.getElementById('mode_moon')
theme.addEventListener('click', (e) => {
const htmlElement = document.documentElement;
if (htmlElement.getAttribute('mode') === 'light') {
htmlElement.setAttribute('mode', 'dark');
sun.classList.toggle('right_mode')
moon.classList.toggle('right_mode')
} else if (htmlElement.getAttribute('mode') === 'dark') {
htmlElement.setAttribute('mode', 'light');
sun.classList.toggle('right_mode')
moon.classList.toggle('right_mode')
} else {
htmlElement.setAttribute('mode', 'dark')
sun.classList.toggle('right_mode')
moon.classList.toggle('right_mode')
}
})