JSFiddle - React, Tailwind, and code Playground

by Amit Saran

HTML

<div class="test">TESTING</div>

CSS

.test {
    padding: 10px;
    float: left;
    background: gray;
}

.test:hover {
    background: pink;
}

JavaScript

var elms = document.getElementsByClassName("test");
var n = elms.length;
function changeColor(color) {
    for(var i = 0; i < n; i ++) {
        elms[i].style.backgroundColor = color;
    }
}
for(var i = 0; i < n; i ++) {
    elms[i].onmouseover = function() {
        //changeColor("gray");
    };
}