Ticket #11690 (closed bug: invalid)
.on('hover' ..) shows two different event types for when logging event and event.type
| Reported by: | christianlaustsen@… | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.7.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
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
comment:1 Changed 13 months ago by rwaldron
- Status changed from new to closed
- Resolution set to invalid
comment:2 Changed 13 months ago by dmethvin
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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

hover is not a real event, it's a cover API for mousenter/mouseleave.
http://api.jquery.com/hover/