CKTIS / HTML
onmouseout — handling a mouse leaving an element
The global onmouseout attribute contains JavaScript code that handles the mouseout event. Use it to respond when the mouse pointer leaves an element.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
onmouseout="JavaScript statements"onmouseout is a global event handler attribute for mouseout, available on HTML elements. Its value is a JavaScript function body, not an event name or a script URL.
The code can access the event parameter. Distinguish the HTML attribute containing code from the JavaScript property element.onmouseout, which accepts a function or null.
mouseout bubbles: a handler on an ancestor can receive a descendant's event. Moving into a child element can also trigger mouseout; it therefore does not always mean leaving the entire subtree. Use mouseleave for that distinction.
In the example, leaving the button sets the paragraph text to mouseout. Script execution must be permitted; Content Security Policy can block inline event handler attributes.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>onmouseout demo</title>
<button type="button" onmouseout="document.getElementById('result').textContent = event.type">Hover, then leave</button>
<p id="result">Ready</p>
</html>Result
mouseout
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.