Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

onmouseleave event

onmouseleave event

Event Object Reference Event Object

Example

Execute JavaScript when the mouse pointer moves out:

Smiley

Try it »

In the more examples below, click "Try it" to see more demonstrations.


Definition and Usage

The onmouseleave event is triggered when the mouse moves out of the element.

Tip: This event is usually used together with onmouseenter event is used together with this event, which is triggered when the mouse moves onto the element.

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


Browser support

The numbers in the table indicate the version number of the first browser to support the event.

Events
onmouseleave 30.0 5.5 Yes 6.1 11.5

Syntax

In HTML:

<

element

onmouseleave="

myScript

">

Try it

In JavaScript:

object

.onmouseleave=function(){

myScript

};

Try it

In JavaScript, use the addEventListener() method:

object

.addEventListener("mouseleave",

myScript

);

Try it

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


Technical Details

Does it support bubbling: No
Is it cancelable: No
Event type: MouseEvent
Supported HTML tags: All HTML elements, except:, ,
, , ,