Web Development with jQuery®

(Elliott) #1

bapp04.indd 02/17/2015 Page 509


Events


The following table contains all the event methods supported by jQuery as listed in jQuery’s
offi cial documentation at http://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 specifi ed 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 events
object data
function(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.

D


continues

http://www.it-ebooks.info

Free download pdf