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 attach a click event to a button.

document.getElementById("myBtn").addEventListener("click", function() {
  alert("Hello World!");
});