Web Development with jQuery®

(Elliott) #1

(^512) ❘ APPENDIX D EVENTS
on(events[, selector][,
data])
string events
string selector
object data
Attaches an event handler for the selected elements; the
elements referenced in the selection must exist at the
time on() is called.
If a selector is provided in the second argument, descen-
dant element(s) referenced by the selector will be the
element(s) receiving the event(s), rather than the original
selection. Elements referenced by the selector may or
may not exist when on() is called. If new descendant
elements matching the selector are created after the
attachment of the event(s), those element(s) automatically
receive the event(s) when they exist.
Custom data can be passed in the data argument; if cus-
tom data is provided it will be available in the event han-
dler, in the event argument, as event.data.
one(events, function)
string events
function(event)
Attaches a function to be fi red for the specifi ed event.
The function is executed only once. Subsequent events
will not execute the specifi ed function.
one(events[, data],
function)
string events
object data
function(event)
The one() method accepts an optional data argument.
The data argument is an object that is passed to the
event object of the attached function as event.data.
one(events[, selector][,
data], function)
string events
string selector
object data
function(event)
Attaches an event handler that is always executed just
once per element and event.
If a selector is provided in the second argument, descen-
dant element(s) referenced by the selector will be the
element(s) receiving the event(s), rather than the original
selection. Elements referenced by the selector may or
may not exist when one() is called. If new descendant
elements matching the selector are created after the
attachment of the event(s), those element(s) automatically
receive the event(s) when they exist.
Custom data can be passed in the data argument; if cus-
tom data is provided, it will be available in the event han-
dler, in the event argument, as event.data.
trigger(events)
string events
Triggers the specifi ed event on matched elements.
(continued)
http://www.it-ebooks.info

Free download pdf