Javascript Mouse Out
The javascript mouse out(onmouseout) event occurs when the mouse pointer is moved out of an element, or out of one of its children.
Syntax:
<element onmouseout="myScript">
Example:
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
border: 1px solid black;
margin: 10px;
float: left;
padding: 30px;
text-align: center;
background-color: lightgray;
}
p {
background-color: white;
}
</style>
</head>
<body>
<h3>Example: difference between onmousemove, onmouseleave and onmouseout.</h3>
<div onmousemove="myMoveFunction()">
<p>onmousemove: <br> <span id="i2-1">Mouse over and leave me!</span></p>
</div>
<div onmouseleave="myLeaveFunction()">
<p>onmouseleave: <br> <span id="i2-2">Mouse over and leave me!</span></p>
</div>
<div onmouseout="myOutFunction()">
<p>onmouseout: <br> <span id="i2-3">Mouse over and leave me!</span></p>
</div>
<script>
var x = 0;
var y = 0;
var z = 0;
function myMoveFunction() {
document.getElementById("i2-1").innerHTML = z+=1;
}
function myLeaveFunction() {
document.getElementById("i2-2").innerHTML = x+=1;
}
function myOutFunction() {
document.getElementById("i3-3").innerHTML = y+=1;
}
</script>
</body>
</html>
OUTPUT:
