Side navigation
#11690 closed bug (invalid)
Opened May 03, 2012 03:09PM UTC
Closed May 03, 2012 04:50PM UTC
Last modified July 25, 2012 05:58AM UTC
.on('hover' ..) shows two different event types for when logging event and event.type
Reported by: | christianlaustsen@gmail.com | 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.
Attachments (0)
Change History (3)
Changed May 03, 2012 04:50PM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
Changed May 05, 2012 02:15AM UTC by comment:2
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/