Answers for "how to add hover effect in js"

0

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;")
}
Posted by: Guest on February-27-2020
0

hover con js

// Creamos el evento mouseover para cada imagen
	imagenes[i].addEventListener("mouseover", function(e){
		document.getElementById("mostrar").style.backgroundImage="url('"+e.target.currentSrc+"')";
	});
 
// Creamos el evento mouseout para cada imagen
imagenes[i].addEventListener("mouseout", function(e){
  document.getElementById("mostrar").style.backgroundImage="";
});
Posted by: Guest on February-08-2021
2

javascript on hover

<img onmouseover="enlargeImage(this)" border="0" src="smiley.gif" alt="Smiley" width="32" height="32">

<script>
function enlargeImage(x) {
  x.style.height = "64px";
  x.style.width = "64px";
}
</script>
Posted by: Guest on April-23-2020

Code answers related to "how to add hover effect in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language