Right now it does not change the color of the background
This is my html code:
<button onclick="light_mode()">Light mode</button>
<button onclick="dark_mode()">Dark mode</button>
this is my javascript:
function dark_mode() {
document.getElementById('body').x.style.background = "color:black";
}
function light_mode() {
document.getElementById('body').x.style.background = "color:white";
}
I gave the body an id "body" so the js would work. Right now it does not work though. Im a beginner at javascript so pls simple explanation. Thank you!
2
Answers
The way you’re doing the changing of the colours is a bit off. Here’s a corrected version of your JavaScript:
And, your HTML should look something like this:
Be sure to let me know if you have any other questions 🙂
you need to change the background color of the inputs, but if everything is black you wont see the input