Web Development with jQuery®

(Elliott) #1

(^64) ❘ CHAPTER 3 EVENTS
The jQuery 2.x branch does away with things such as legacy support for older versions of Internet
Explorer, so the 2.x branch will not provide universal event support.
With the differences in browser support safely behind us for the most part, the jQuery event API has
taken up the task of making it easier to work with events in JavaScript in general, and it succeeds
well at doing so. The fi rst collection of methods you take a look at in this chapter are a collection of
methods that provide API wrappers around the most-used events in JavaScript. These methods make
it possible to do two things:
➤ (^) To easily attach a callback function to an event
➤ (^) To easily trigger an event
You can fi nd a comprehensive list of event methods in Appendix D, “Events.”
The following example demonstrates the jQuery event wrapper method, click(). Remember, this and
all examples are available for free with the book’s source code download materials from http://www.wrox.com/
go/webdevwithjquery. This example is available in the accompanying materials as Example 3-1.html.
<!DOCTYPE HTML>






Finder










Applications





Library





Network





Sites
[http://www.it-ebooks.info](http://www.it-ebooks.info)