11. Events

Events are hugely important to client-side programming. Without them, you couldn’t add interactivity to web pages beyond clicking links and submitting forms.

Using events is a matter of executing a function in response to an action or input. These functions are known as event listeners or event handlers. I prefer handler even though some method names use listener. (Would a function handle an event or listen for an event? The former makes more sense to me.)

You can add event handlers to page elements in two ways, and Internet Explorer throws a wrench into the works by providing a completely different event API from every other modern browser. Handling events properly across all browsers can be pretty tricky, but fortunately JavaScript ...

Get The JavaScript PocketGuide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.