Event Methods

The methods in this section are for registering event handlers and triggering events; see Chapter 4.

event-type()event-type(f(event))

Register f as a handler for event-type, or trigger an event of event-type. jQuery defines the following convenience methods that follow this pattern:

ajaxComplete blur     focusin  mousedown  mouseup
ajaxError    change   focusout mouseenter resize
ajaxSend     click    keydown  mouseleave scroll
ajaxStart    dblclick keypress mousemove  select
ajaxStop     error    keyup    mouseout   submit
ajaxSuccess  focus    load     mouseover  unload
bind(type, [data], f(event))bind(events)

Register f as a handler for events of the specified type on each of the selected elements. If data is specified, add it to the event object before invoking f. type may specify multiple event types and may include namespaces.

If a single object is passed, treat it as a mapping of event types to handler functions, and register handlers for all the specified events on each selected element.

delegate(sel, type, [data], f(event))

Registers f as a live event handler. f will be triggered when events of type type occur on an element matching sel and bubble up to any of the selected elements. If data is specified, it will be added to the event object before f is invoked.

die(type, [f(event)])

Deregisters live event handlers registered with live() for events of type type on elements that match the selector string of the current selection. If a specific event handler function f is specified, only deregister that one.

Get jQuery Pocket Reference 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.