Last Updated : 15 Jun, 2023
The DOM onmouseleave event in HTML occurs when the mouse pointer is moved out of an element. This event is the opposite of onmouseleave event.
This event is similar to the onmouseover event.
Supported Tags: It supports All HTML elements, EXCEPT:
Syntax:
<element onmouseleave="myScript">
object.onmouseleave = function(){myScript};
object.addEventListener("mouseleave", myScript);
Example: Using the addEventListener() method
HTML
<!DOCTYPE html>
<html>
<head>
<title>
HTML DOM onmouseenter Event
</title>
</head>
<body>
<h1 id="demo">
GeeksforGeeks
</h1>
<h2>
HTML DOM onmouseleave Event
</h2>
<script>
document.getElementById(
"demo").addEventListener(
"mouseenter", enter);
document.getElementById(
"demo").addEventListener(
"mouseleave", leave);
function enter() {
document.getElementById(
"demo").style.color = "yellow";
}
function leave() {
document.getElementById(
"demo").style.color = "green";
}
</script>
</body>
</html>
Output:
Supported Browsers: The browsers supported by HTML DOM onmouseleave Event are listed below:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4