Hello there! I've been working on implementing a "dark mode/light mode" feature for my website. My approach involves using two different CSS style sheets and toggling between them using a single button
So far, I've experimented with various methods like setAttribute, innerHTML, and removeAtribute to achieve this functionality. I even tried moving the contents of one style sheet into <style>
tags but couldn't get it to work as intended.
Switch to Light Mode
function light(){
document.getElementById("css").setAttribute("href", "LIGHTMODE.CSS")
document.getElementById("darkmode").innerHTML = "Switch to Light Mode"
document.getElementById("darkmode").onclick = "dark()"
}
function dark(){
document.getElementById("css").setAttribute("href", "DARKMODE.CSS")
document.getElementById("darkmode").innerHTML = "Switch to Dark Mode"
document.getElementById("darkmode").onclick = "light()"
}
The goal is to identify the elements by their IDs and dynamically change the href attribute based on user interaction