JSFiddle - React, Tailwind, and code Playground
HTML
<div id="foo">
</div>
<button id="btn">button</button>
CSS
#foo {
background-color: orange;
width: 100px;
height: 100px;
}
#foo:hover {
background-color: red;
}
JavaScript
var f = document.getElementById('foo');
var btn = document.getElementById('btn');
btn.onclick = function() {
if (f.style.length > 0)
f.style.removeProperty('background-color');
else
f.style.backgroundColor = 'red';
}