Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

PART 2: Working with jQuery > CHAPTER 9: Working with Events - Pg. 253

CHAPTER 9 Working with Events In this chapter, I describe the jQuery support for events. If you are unfamiliar with events, then I provided a very brief overview of how they work and how they are propagated through the DOM in Chapter 2. jQuery provides some very nice event-related features, of which my favorite is the ability to automatically associate event handler functions with elements as they are added to the DOM. Table 9-1 provides the summary for this chapter. Table 9-1. Chapter Summary Problem Register a function to handle one or more event. Suppress the default action for an event. Solution Use the bind method or one of the shorthand methods. Use the Event.preventDefault method or use the bind method without specifying a handler function. Use the unbind method. Listing 1­4, 18, 19, 22 5­6 Remove an event handler function from an element. Create a handler function that is executed only once for each element it is associated with. Automatically apply an event handler function to elements as they are added to the document. Remove a handler created using the live method. Apply an automatically added handler to a specific element in the DOM. 7­9 Use the one method. 10 Use the live method. 11, 12 Use the die method. 13 Use the delegate and undelegate methods. 14 223