Chapter 3Events

jQuery offers a powerful and comprehensive event API. jQuery's event API provides wrapper methods that accommodate most events in JavaScript. jQuery's event API also provides the capability to attach events it doesn't explicitly support via its event methods. The jQuery event API even has the capability to apply events to elements that might not even exist in the document yet. Events can be neatly organized and namespaced within jQuery, another feature it offers above and beyond the baseline provided by JavaScript. Your events can be neatly organized into named categories, which make it a lot easier to manage events. Having named events also makes it possible to easily remove them.

In this chapter, you learn everything you need to know to work with jQuery's event API. You learn how to use jQuery's event wrapper methods such as click() or hover(). You also learn how to use methods such as on() and off(). You can use the on() and off() methods to attach an event handler function to any event, whether it is a native JavaScript event or a custom event that you've created. The on() and off() methods can also attach events to elements that might not even exist in the document yet. In addition, on() and off() can name and organize events, which is useful if you need to manage or remove events as easily as creating them. You also learn how to create completely custom events for your applications by virtue of the trigger() method as well as the on() and off() methods. ...

Get Web Development with jQuery now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.