O'Reilly logo

Professional jQuery by Rob Larsen, Cesar Otero

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

Chapter 5

Event Handling

WHAT’S IN THIS CHAPTER?

  • Understanding the Browser Event Model
  • Understanding How jQuery Handles Events
  • Working with jQuery Events

Any GUI-based modern application is inherently event-driven, and web applications are no exception. All event-driven applications follow the familiar pattern of setting up event-handling mechanisms, waiting for an interesting event to occur (such as a mouse click), and responding to that event. Beyond the normal clicking and key-pressing events, there’s also page loading and other semantic events, as well as the more recently added events such as swipe gestures, which are now important given the popularity of touch devices such as iPhones and Android. Events are fundamental to the Web; the use of JavaScript is seriously limited without them. The jQuery docs categorize event methods into document loading, form events, event-handler attachments, mouse events, browser events, methods related to the Event object, and keyboard events.

Most likely, at some point in your career as a developer you’ve heard about the various cross-browser issues that plague web development. How different browsers manage events is one of the most significant cross-browser problems.

In this chapter you review basic JavaScript event handling, both DOM level 0 and level 2, event propagation, bubbling, and Internet Explorer’s event model to get a better understanding of what’s going on under the hood. Then you translate that knowledge over to jQuery’s event-handling ...

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