This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.



Smartphone icons created by Freepik - Flaticon

JS addEventListener()

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

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!
"; }