jQuery in Action

102
CHAPTER 4
Events are where it happens!
In addition to the
bind()
command, jQuery provides a handful of shortcut
commands to establish specific event handlers. Because the syntax of each of
these commands is identical except for the method name of the command, we'll
save some space and present them all in the following single syntax descriptor:
jQuery also provides a specialized version of the
bind()
command, named
one()
,
that establishes an event handler as a one-shot deal. Once the event handler exe-
cutes the first time, it's automatically removed as an event handler. Its syntax is
similar to the
bind()
command and is as follows:
Command syntax: specific event binding
eventTypeName(listener)
Establishes the specified function as the event handler for the event type named by the
method's name. The supported commands are as follows:
blur
change
click
dblclick
error
focus
keydown
keypress
keyup
load
mousedown
mousemove
mouseout
mouseover
mouseup
resize
scroll
select
submit
unload
Note that when using these shortcut methods, we cannot specify a data value to be placed
in the event.data property.
Parameters
listener
(Function) The function that's to be established as the event handler.
Returns
The wrapped set.
Command syntax: one
one(eventType,data,listener)
Establishes a function as the event handler for the specified event type on all elements in
the matched set. Once executed, the handler is automatically removed.
Parameters
eventType
(String) Specifies the name of the event type for which the handler is to be
established.
data
(Object) Caller-supplied data that's attached to the Event instance for avail-
ability to the handler functions. If omitted, the handler function can be spec-
ified as the second parameter.
listener
(Function) The function that's to be established as the event handler.
Returns
The wrapped set.


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.