Web Development with jQuery®

(Elliott) #1

Summary (^) ❘ 87
Event handlers can be absolutely controlled, added, and removed at will. The off() method provides
the mechanism to remove an event. Removing an event requires calling the off() method with the
name of the event or the event namespace, or both.
Calling an event wrapper method with no arguments, for example calling click() as well as calling
trigger(), can trigger an event handler.
Custom events can be created and used with the standard jQuery event API. The on(), off(), and
trigger() methods can all create custom events. You also saw some examples in this chapter of
some custom events you might apply to a fi le manager application.
EXERCISES



  1. Name all the methods you can use to attach a mouseover event using jQuery.


Extra Credit: How would you attach both a mouseover and mouseout event using the same


method? Hint: This answer can be found in Appendix D.



  1. What method would you use to attach any browser event not already provided as a wrapper


method?



  1. What event property is used as the basis for determining what element has received an event


using jQuery’s persistent or live events? Explain what happens.



  1. How do you use a persistent or live event to create an event handler?

  2. How do you name an instance of an event handler? How do you apply multiple names to an


instance of an event handler?



  1. What method is used to remove an event handler?

  2. Can an event handler be removed by virtue of its named instance only?

  3. Name two ways to fi re a click event handler using script.

  4. How do you create a custom event handler? How do you send data to a custom event


handler?


http://www.it-ebooks.info

Free download pdf