-
Book Overview & Buying
-
Table Of Contents
Learning jQuery : Better Interaction Design and Web Development with Simple JavaScript Techniques
The mouseout scenario just described illustrates the need to constrain the scope of an event. While .hover() handles this specific case, we will encounter other situations in which we need to limit an event spatially (preventing the event from being sent to certain elements) or temporally (preventing the event from being sent at certain times).
We have already seen one situation in which event bubbling can cause problems. To show a case in which .hover() does not help our cause, we’ll alter the collapsing behavior we implemented earlier.
Suppose we wish to expand the clickable area that triggers the collapsing or expanding of the style switcher. One way to do this is to move the event handler from the label to the containing <div> element:
$(document).ready(function() {
$('#switcher').click(function() {
$('#switcher .button').toggleClass('hidden');
});
});This alteration makes the entire area of the style switcher clickable to...
Change the font size
Change margin width
Change background colour