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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.