a place to learn javascript for today's world.

Event Listeners

Event Listeners are how you enable an element to respond to different events. By default events bubble down the DOM tree so that a single action can trigger multiple events.

Event Listeners

  • add event listener: mySelection.addEventListener('click', foo);

    Common Event Listeners

  • onload -- when the page loads
  • onclick -- when a user clicks something
  • onmouseover -- when a user mouses over something
  • onfocus -- when a user puts the cursor in a form field
  • onblur -- When a user leaves a form field