Java Script Snippet

Intercettare gli eventi di Mouse Over, Mouse Out e Click




This example uses the addEventListener() method to add many events on the same button.




&ltbutton id="myBtn"&gt Try it &lt/button&gt

&ltscript&gt
var x = document.getElementById("myBtn");
x.addEventListener("mouseover", myFunction);
x.addEventListener("click", mySecondFunction);
x.addEventListener("mouseout", myThirdFunction);

function myFunction() {
  document.getElementById("demo").innerHTML = "Moused over!
"
}

function mySecondFunction() {
  document.getElementById("demo").innerHTML = "Clicked!
"
}

function myThirdFunction() {
  document.getElementById("demo").innerHTML = "Moused out!
"
}
&lt/script&gt

Guarda il codice su CodePen
info@giannimessina.it