Appendix D

Events

The following table contains all the event methods supported by jQuery as listed in jQuery's official documentation at www.jquery.com.

All the event methods return the jQuery object.

Method Description
Page Load
ready(function)function(event) Attaches a function that is executed when the DOM is completely loaded; that is, all markup, CSS, and JavaScript are loaded, but not necessarily images.
Event Handling
bind(events, function)string events function(event) Attaches a function that is executed when the event occurs. Multiple events can be specified in the event argument; if you specify multiple events, each event must be separated with a single space.The on() method is preferred over bind() in jQuery 1.7 or later.
bind(events[, data][, function])string eventsobject datafunction(event) The bind() method accepts an optional data argument. The data argument is an object that allows you to pass custom data to the event, which is available in the event handler, in the event argument as event.data.The on() method is preferred over bind() in jQuery 1.7 or later.
bind(events[, data][, preventBubble])string eventsobject databoolean preventBubble When calling the bind() method with the preventBubble argument, an event handler is automatically created, which prevents bubbling, as well as the default action.
bind(eventName, false); 

or

bind(eventName);

is equivalent to creating the following:

bind(
    eventName,
    function(event)
    {
 event.preventDefault(); ...

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.