Latest web development tutorials

onmouseleave event

Event Object Reference Event objects

Examples

JavaScript is executed when the mouse pointer moves pointers:

<Img onmouseleave = "normalImg (this)" src = "smiley.gif" alt = "Smiley">

try it"

In the following examples more point "try" to see more demonstrations.


Definition and Usage

onmouseleave event fires when the mouse is removed elements.

Note: This event is usually associated with onmouseenter used in conjunction with the event, the event triggered when the mouse moves over the element.

Tip: onmouseleave events similar to the onmouseout event. The only difference is that events do not support onmouseleave bubbling.


Browser Support

Figures in the table represent the first browser to support this version of events.

event
onmouseleave 30.0 5.5 Yes 6.1 11.5


grammar

In HTML:

<Elementonmouseleave = "myScript"> try

In JavaScript:

object .onmouseleave = function () {myScript }; try

JavaScript, use the addEventListener () method:

object .addEventListener ( "mouseleave", myScript ); try

Note: Internet Explorer 8 and earlier versions of IE do not support addEventListener () method.


technical details

Whether to support the bubble: No
It can be canceled: No
Event Type: MouseEvent
Supported HTML tags: All HTML elements except: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>


Examples

More examples

Examples

This example demonstrates the difference between onmousemove, onmouseleave and onmouseout event:

<Div onmousemove = "myMoveFunction ()">
<P id = "demo"> I will demonstrate onmousemove! </ P>
</ Div>

<Div onmouseleave = "myLeaveFunction ()">
<P id = "demo2"> I will demonstrate onmouseleave! </ P>
</ Div>

<Div onmouseout = "myOutFunction ()">
<P id = "demo3"> I will demonstrate onmouseout! </ P>
</ Div>

try it"

Event Object Reference Event objects