JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<p>Testing paragraph</p>
<p>Testing paragraph</p>
</div>
<div>
<p>Testing paragraph</p>
<p>Testing paragraph</p>
</div>
CSS
div {
background-color: green;
}
p {
background-color: yellow;
}
.hovered,
.hovered * {
cursor: pointer;
color: black;
background-color: red;
}
JavaScript
var last,
bgc;
document.onmouseover = function(e) {
var elem = e.target;
if (last != elem) {
if (last != null) {
last.classList.remove("hovered");
}
last = elem;
elem.classList.add("hovered");
}
}