1. Home
  2. Javascript
  3. Add event listener

Adds an event listener to an object. Once the event in triggered function passed as the second argument is fired.

#javascript#event
object.addEventListener("click", function(){
    // do something
});
copy
Full Javascript cheatsheet