O'Reilly logo

Sams Teach Yourself JavaScript™ in 24 Hours, Fifth Edition by Phil Ballard, Michael Moncur

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

Hour 9. Responding to Events

What You’ll Learn in This Hour

• More on JavaScript’s built-in event handlers

• Adding and removing your own event handlers

• Using event handling for form validation

In this hour you learn what event handling is about and how to write proper cross-browser event handlers for your scripts.

Understanding Event Handlers

To a scripting language seeking to add interactivity to web pages, events are fundamental; the user does something (causes some event to fire), and the page reacts to that event. Therefore JavaScript needs a way of detecting user actions so that it knows how to react appropriately.

There are also some events that aren’t caused directly by user interaction, for example, the window.onload event introduced ...

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