Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In this chapter, we're going to handle working with events in jQuery. So jQuery provides a mechanism for working with events that is simpler than relying on the Document Object Model. And if you've ever worked with events in modern webpage development, one of the things you've probably noticed is that it's pretty frustrating because the different browsers have different ways of working with the modern event implementations. Specifically, IE has its own way of attaching events to and disconnecting them from elements, which is separate from the DOM Level 2 Specification, which is what a lot of the other browsers follow.
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 seen. So jQuery events basically break down into a couple of categories. The first is the Binding and Unbinding category. These functions allow you to wire events up, and take them off of elements in a simple cross-browser way.
And we'll see an example of that in a moment. The next is the Unified Event Object. Another thing that you've probably noticed if you've done web development or cross-browsers with modern events is that the event object is slightly different between the IE browsers and other browsers, and 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.
Then finally there is a bunch of convenience features and these are basically functions that encapsulate a lot of common event features and helper routines that work cross-browsers and we'll see an example of those as well. So now that we understand what event handling in jQuery is and what we are going to do, let's see a good example.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 97424 Viewers
61 Video lessons · 84654 Viewers
71 Video lessons · 68860 Viewers
56 Video lessons · 101318 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.