[UPHPU] jquery: hover(over,out)

Joseph Scott joseph at randomnetworks.com
Tue Dec 9 08:50:45 MST 2008


On Dec 8, 2008, at 11:07 PM, Wade Preston Shearer wrote:

>>
>> Because hover() takes Functions as arguments, and what you are  
>> doing is calling the functions when setting up the hover event.
>
> I considered "takes Functions as arguments" and "calling the  
> functions" as the same thing. The documentation words it as the  
> "specified function is fired." It doesn't specify that the functions  
> have to be anonymous, in-line functions. Too bad; I would have liked  
> to have called external functions and not repeated code.



Calling functions and passing functions (which can be anonymous or  
addressed as a variable) are completely different.  Calling a function  
will cause it to be fired immediately, by passing and an anonymous  
function or function reference this allows jQuery to fire them at the  
appropriate time.  That's really the key to why they need to be  
referenced functions, so that .hover() can control when they are fired.

There's nothing stopping your from calling your external function, as  
the hover example showed:

	http://docs.jquery.com/Events/hover#overout

What you're trying to do is avoid the extra 12 characters (or more  
with spaces) per argument to the .hover() function.

--
Joseph Scott
joseph at josephscott.org
http://josephscott.org/






More information about the UPHPU mailing list