Java Script Snippet

Java Script Snippet,School,Senza categoria

Intercettare gli eventi di Mouse Over, Mouse Out e Click

17 Nov , 2021  



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
Like
Like Love Haha Wow Sad Angry

,


Comments are closed.

RSS Open school