15. Learning About an Event

In Chapter 12, we looked at how to use event handlers to trigger JavaScript functions. An event handler can be applied to various objects on the page to tell the object how to react when a particular action occurs. However, events also include information about how a particular event was generated, such as which event type occurred, what object generated the event, and (for keyboard and mouse events) which button was pressed.

In this chapter, you’ll learn how to find the information generated by an event and how to process it.

Detecting Which Event Type Fired

Once an event is fired, the function it triggers doesn’t inherently know how it was triggered. The type event property can tell you what event type was fired, ...

Get CSS, DHTML, and Ajax: Visual QuickStart Guide, Fourth Edition 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.