I have been trying to make a toggle button that when pressed, would turn the page black for my own eyes sake, but have been unable to do so. Here is how it looks when i try: https://gyazo.com/5cd21085350b603f9289bb5f64b2361e I'am not good with JavaScript so its not that complicated. I have my button that looks like this:
<label class="switch" onclick="pagecolor();">
<input type="checkbox">
<span class="slider round"></span>
</label>
And here is my JavaScript:
function pagecolor(){
if(document.body.style.backgroundColor = "white") {
document.body.style.backgroundColor = "black";
} else {
document.body.style.backgroundColor = "white";
}
}
Hope you can help :)