jQuery in Action

110
CHAPTER 4
Events are where it happens!
In this example, we apply the
toggle()
command
b
to the images supplying an
odd listener
c
that reduces the opacity value to 0.4 (graying out the image, a com-
mon term for indicating disablement) and an even listener that restores the opac-
ity to its full value of 1.0
d
. Because the
toggle()
command handles all the
swapping out for us, we don't need to bother keeping track of whether the current
click is odd or even. How convenient.
All we accomplished in this example was the toggling of the image from full to
partial opacity, but it's easy to imagine supplying listeners that would toggle any
complementary states: enabled versus disabled, for example.
Another common multi-event scenario that's frequently employed in Rich
Internet Applications involves mousing into and out of elements.
Hovering over elements
Events that inform us when the mouse pointer has entered an area, as well as when
it has left that area, are essential to building many of the user interface elements
that are commonly presented to users on our pages. Among these element types,
the menus used as navigation systems for web applications are a common example.
A vexing behavior of the mouseover and mouseout event types often hinders
the easy creation of such elements when a mouseout event fires as the mouse is
moved over an area and its children. Consider the display in figure 4.9 (available
in the file chapter4/hover.html).
This page displays two identical (except for naming) sets of areas: an outer
area and an inner area. Load this page into your browser as you follow the rest of
this section.
Figure 4.9
This page helps
demonstrate when
mouse events fire as
the mouse pointer is
moved over an area
and its children.


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

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