Mouse Events
There are quite a few mouse-related events. Table 17-1 lists them all. All mouse events except “mouseenter” and “mouseleave” bubble. Click events on links and Submit buttons have default actions that can be prevented. You may be able to cancel a context menu event to prevent the display of a context menu, but some browsers have configuration options that make context menus noncancelable.
Table 17-1. Mouse events
Type | Description |
---|---|
click | A higher-level event fired when the user presses and releases a mouse button or otherwise “activates” an element. |
contextmenu | A cancelable event fired when a contextmenu is about to be popped up. Current browsers display context menus on right mouse clicks, so this event can also be used like the click event. |
dblclick | Fired when the user double-clicks the mouse |
mousedown | Fired when the user presses a mouse button |
mouseup | Fired when the user releases a mouse button |
mousemove | Fired when the user moves the mouse. |
mouseover | Fired when the mouse enters an element. |
mouseout | Fired when the mouse leaves an element. |
mouseenter | Like “mouseover”, but does not bubble. Introduced by IE and standardized in HTML5 but not yet widely implemented. |
mouseleave | Like “mouseout”, but does not bubble. Introduced by IE and standardized in HTML5 but not yet widely implemented. |
The object passed to mouse event handlers ...
Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.