javascript add event listener to option hover code example
Example 1: get hover element js
let test = document.getElementById("test");
test.addEventListener("mouseenter", function( event ) {
event.target.style.color = "purple";
setTimeout(function() {
event.target.style.color = "";
}, 500);
}, false);
Example 2: hover vanilla javascript
var target = document.querySelector(".button");
target.addEventListener("mouseover", mOver, false);
target.addEventListener("mouseout", mOut, false);
function mOver() {
target.setAttribute("style", "background-color:blue;")
}
function mOut() {
target.setAttribute("style", "background-color:green;")
}