Onmouseleave event
JavaScript is performed when the mouse pointer moves out of the pointer:
Try it out . . .
"Try it" in more instances below to see more demos.
Definitions and usages
The onmouseleave event is triggered when the mouse removes the element.
Tip: This event is typically used with the onmouseenter event, which is triggered when the mouse moves over the element.
Tip: The onmouseleave event is similar to the onmouseout event. T he only difference is that the onmouseleave event does not support bubbling.
Browser support
The numbers in the table support the version number of the first browser for the event.
Event | |||||
---|---|---|---|---|---|
onmouseleave | 30.0 | 5.5 | Yes | 6.1 | 11.5 |
Grammar
In HTML:
In JavaScript:
In JavaScript, use the addEventListener() method:
Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions of IE.
Technical details
Whether to support bubbling: | No |
---|---|
Can I cancel: | No |
Types of events: | MouseEvent |
Supported HTML tags: | All HTML elements, except: slt;bdo>, slt;br?gt;,?lt;head>,?lt;html>, slt;iframe?gt;, slt;meta?gt;,.lt;param>, slt;script&script;,?lt;style>and slt;title> |
More instances
This example demonstrates the difference between onmousemove, onmouseleave, and onmouseout events:
I'm going to demonstrate onmousemove!
</div>
<div onmouseleave="myLeaveFunction()">
I'm going to demonstrate onmouseleave!
</div>
<div onmouseout="myOutFunction()">
I'm going to demonstrate onmouseout!
</div>
Try it out . . .