#11690 closed bug (invalid)
.on('hover' ..) shows two different event types for when logging event and event.type
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This was tested in Google Chrome v. 18.0.1025.168 if that matters :)
Using this code:
$(document).on('hover', '.item', function(event) { console.log(event); console.log(event.type); });
On mouseenter it shows: Output from event: jQuery.Event
... toElement: HTMLImageElement type: "mouseover" ...
Output from event.type: mouseenter
On mouse out it does: Output from event: jQuery.Event
... toElement: HTMLImageElement type: "mouseout" ...
Output from event.type: mouseleave
When trying to catch the event, it only responds to mouseenter/mouseleave and not mouseover/mouseout.
Example, this runs console.log():
$(document).on('hover', '.item', function(event) { if (event.type == "mouseenter") { console.log('Success'); } });
while this doesn't:
$(document).on('hover', '.item', function(event) { if (event.type == "mouseover") { console.log('Success'); } });
You can send me an email if you have any further questions.
Change History (3)
comment:1 Changed 11 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 Changed 11 years ago by
Although strongly discouraged for new code, you may see the pseudo-event-name
"hover"
used as a shorthand for the string"mouseenter mouseleave"
. It attaches a single event handler for those two events, and the handler must examine event.type to determine whether the event is mouseenter or mouseleave. Do not confuse the"hover"
pseudo-event-name with the.hover()
method, which accepts one or two functions.
hover
is not a real event, it's a cover API for mousenter/mouseleave.http://api.jquery.com/hover/