O'Reilly logo

Modern JavaScript: Develop and Design by Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8. Event Handling

Handling events is one of the fundamental uses of JavaScript. Loading a Web page, moving the cursor, entering text into a textarea, submitting a form: these are all events that occur within the browser to which JavaScript can respond. Out of necessity, Chapter 2, JavaScript in Action, introduced the very basics of event handling, and it also presented two events, used in most of the book’s examples thus far. In this chapter, you’ll learn everything you need to know to handle the myriad of events in JavaScript.

The Premise of Event Handling

Chapter 2 explained that creating an event handler in JavaScript is a matter of associating an event and an object with a JavaScript function. For example:

window.onload = init;

That one line ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required