As you can see, I have a javascript which is supposed to make a darkmode switch on a website. javascript works I get the alert but nothing happens when I press the switch. Why? Note: I am very new to programming and stuff, so explanations for an idiot would be great. ----example.html----
<a href="#" class="right">
<button type="button" onclick="func()">Darkmode</button>
</a>
---script.js---
let darkmode = 0
function func() {
if(darkmode = 0){
document.getElementById("main").style.background = "grey";
document.getElementById("row").style.background = "grey";
document.getElementById("footer").style.background = "grey";
darkmode = 1;}
else{
document.getElementById("main").style.background = "white";
document.getElementById("row").style.background = "white";
document.getElementById("footer").style.background = "white";
darkmode = 0;}
}
alert("11 hot singles in your area");
----style.css---- (f.e. the main stuff from css)
/* Main column */
.main {
-ms-flex: 70%; /* IE10 */
flex: 70%;
background-color: white;
padding: 20px;
}