JSFiddle - React, Tailwind, and code Playground

by c_vilander

HTML

<div id="boxone"></div>

CSS

#boxone {
    position: relative;
    top: 5px;
    left: 5px;
    padding: 0;
    margin: 5px;
    width: 100px;
    height: 100px;
    background: red;
}

JavaScript

(function () {
    "use strict";
    
    var x = document.getElementById('boxone');
        x.addEventListener('click',function(){alert("JavaScript");}, false);

    boxone.onclick = function () {

        if (x.style.background === "blue") {
            x.style.background = "red";

        } else {
            x.style.background = "blue";
        }
    };
    
})();