JQuery Quandary

  1. Why am I seeing “hover” “mouseenter/mouseleave” and “mouseover”?

.mouseover(): source

Bind an event handler to the “mouseover” JavaScript event, or trigger that event on an element.

.hover(): source

Bind one or two handlers to the matched elements, to be executed when the mouse pointer enters andleaves the elements.

Calling $(selector).hover(handlerIn, handlerOut) is shorthand for: $(selector).mouseenter(handlerIn).mouseleave(handlerOut);

.mouseenter(): source

Bind an event handler to be fired when the mouse enters an element, or trigger that handler on an element.

mouseover fires when the pointer moves into the child element as well, while mouseenter fires only when the pointer moves into the bound element.

What this means

Because of this, .mouseover() is not the same as .hover(), for the same reason .mouseover() isnot the same as .mouseenter().

$('selector').mouseover(over_function) // may fire multiple times

// enter and exit functions only called once per element per entry and exit
$('selector').hover(enter_function, exit_function) 

from Nerketur Kamachi at Mouseover vs Hove

2. Why am I seeing “hover” “mouseenter/mouseleave” and “mouseover”?

 

“In OO [object oriented] world, the two are commonly used to mean the same thing.

From a pure Math and CS perspective, a function will always return the same result when called with the same arguments ( f(x,y) = (x + y) ). A method on the other hand, is typically associated with an instance of a class. Again though, most modern OO languages no longer use the term “function” for the most part. Many static methods can be quite like functions, as they typically have no state (not always true).”

from TheSoftwareJedi at the Difference between a Method and a Function

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s