JSFiddle - React, Tailwind, and code Playground
HTML
<span id="myIcon">Id span!</span>
<span class="myIcon">Class span!</span>
JavaScript
var myIcon_class = document.getElementsByClassName('myIcon')[0]; //note, gets first element
var myIcon = document.getElementById('myIcon')
myIcon.onmouseover = function() {
alert("hovered on ID!");
return false;
};
myIcon_class.onmouseover = function() {
alert("hovered on class!");
return false;
}