JSFiddle - React, Tailwind, and code Playground

by Kevin Faulhaber

HTML

<div id="container"></div><button id="lightSwitch">Switch</button>

CSS

#container {
    width: 500px;
    height: 500px;
}

JavaScript

var swit = document.getElementById('lightSwitch');
var container = document.getElementById('container');
swit.onclick = function(){
    var color = container.style.backgroundColor;
        if(color === 'white'){
            container.style.backgroundColor = 'black';
        }else{
            container.style.backgroundColor = 'white';
        }
};