addEventListener

  • Sometimes it's helpful to add event listeners in JavaScript
  • This keeps the HTML a bit cleaner
  • Less awkward for creating listeners for elements that were created in JS
  • Provide the event to watch for and the function to call
  • Don't put "on" in the event name

15 / 17