From the course: jQuery Essential Training

jQuery event handling features - jQuery Tutorial

From the course: jQuery Essential Training

Start my 1-month free trial

jQuery event handling features

- Building any kind of modern web application today means that you have to handle all kinds of user generated events. Events are the foundation of the kinds of features that users expect from great web apps today. Drag and drop, shortcut keys, rich animations, you get the idea. In the old days before browsers settled on using the modern W3C standard event API, this was a hard problem to solve because different browsers used different event APIs. Today, the major modern browsers have standardized around the new event APIs but using them is still harder than it needs to be and if you have to support older browsers, then you're still stuck with the same compatibility problem. jQuery provides a mechanism for working with events that's simpler than relying on the document object model and the W3C APIs, and because jQuery works with sets of elements by default, it's very easy to write code that assigns event handlers to groups of objects just by using the results of the selectors and filters that we've already learned about. In this chapter, we'll see how to use jQuery to wire up your page events and then dynamically turn them on and off as you need them. Then we'll see how to use jQuery's unified event object. Even though today's browsers have standardized around the W3 event API, the properties that are passed to event handler functions differ between browsers. jQuery solves that problem by creating a unified event object that exposes the properties and methods that you use most commonly in a cross-browser way. Finally we'll learn about some event convenience functions that encapsulate a lot of common event related features. These functions address common event scenarios that let you accomplish tasks with less code that's easier to read and maintain. Let's get started by looking at how to use jQuery to wire up event handlers in a webpage.

Contents