Get the element the cursor just exited:
<!DOCTYPE html> <html> <body> <p onmouseover="getRelatedElement(event)">Mouse over this paragraph.</p> <p id="demo"></p> <script> function getRelatedElement(event) { document.getElementById("demo").innerHTML = "The cursor just exited the " + event.relatedTarget.tagName + " element."; } </script>//www . j av a2 s .c om </body> </html>
The relatedTarget property returns the element related to the element that triggered the mouse event.
The relatedTargert property can be used with the mouseover event to indicate the element the cursor just exited, or with the mouseout event to indicate the element the cursor just entered.
This property is read-only.
The relatedTarget property returns a reference to the related element.