forked from GarimaSingh0109/WasteManagment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
30 lines (26 loc) · 1007 Bytes
/
script.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
const themeSwitch = document.getElementById('theme-switch');
const body = document.body;
const header = document.querySelector('header');
const footer = document.querySelector('footer');
// Function to enable dark mode
function enableDarkMode() {
body.classList.add('dark-mode');
header.classList.add('dark-mode');
footer.classList.add('dark-mode');
themeSwitch.classList.add('dark-theme'); // Update the switch appearance
}
// Function to disable dark mode
function disableDarkMode() {
body.classList.remove('dark-mode');
header.classList.remove('dark-mode');
footer.classList.remove('dark-mode');
themeSwitch.classList.remove('dark-theme'); // Update the switch appearance
}
// Event listener for dark mode toggle button
themeSwitch.addEventListener('click', () => {
if (body.classList.contains('dark-mode')) {
disableDarkMode(); // Switch to light mode
} else {
enableDarkMode(); // Switch to dark mode
}
});