vanilla js hober code example

Example 1: addeventlistener hover js

let test = document.getElementById("test");

test.addEventListener("mouseover", function( event ) {
  alert("mouse over test!")
  , 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;")
}