Event methods

To react to user behavior, we need to register our handlers using these event methods. Note that many DOM events only apply to certain element types; these subtleties are not covered here. Event methods are discussed in detail in Chapter 3, Handling Events.

Binding

Event method

Description

.ready(handler)

Binds handler to be called when the DOM and CSS are fully loaded.

.on(type, [selector], [data], handler)

Binds handler to be called when the given type of event is sent to the element. If selector is provided, performs event delegation.

.on(events, [selector], [data])

Binds multiple handlers for events as specified in the events object parameter.

.off(type, [selector], [handler])

Removes bindings on the element. ...

Get Learning jQuery - Fourth Edition 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.