Events
onpointerleave
A pointer leaves the element and its descendant boundaries. Event defined by a related web API or specification, not simply a portable HTML global handler. Use addEventListener on the actual target; inline handler exposure and browser support may differ. Event interface: PointerEvent. For the described native event: bubbles: no; cancelable: no. Does not bubble; touch contact ending may cause it even without hover. Example: Interact with the button using a supported pointing device. The event listener is registered with addEventListener(), which avoids inline script handlers and supports multiple listeners. Inline handlers require a CSP that permits them; do not insert untrusted code into handler attributes.
Formal Syntax & Structure
html syntaxhtml
target.addEventListener("pointerleave", event => { /* handle event */ });Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| event | PointerEvent | Event object delivered to the addEventListener callback; event.type is "pointerleave". Inspect target, currentTarget, bubbles and cancelable as appropriate. |
Working Example
Example Snippethtml
<button id="demo" type="button">Pointer test</button><p role="status" id="log">Waiting for pointerleave</p><script> const target = document.getElementById("demo"); const log = document.getElementById("log"); target.addEventListener("pointerleave", event => { log.textContent = String(event.type + ": " + event.pointerType); });</script>