Javascript examples for DOM:Mouse Event
The relatedTarget property returns the element related to the element.
In the mouseover event the relatedTargert property indicates the element the cursor just exited.
In the mouseout event the relatedTargert property indicate the element the cursor just entered.
This property is read-only.
The following code shows how to get the element the cursor just exited:
<!DOCTYPE html> <html> <body> <p onmouseover="getRelatedElement(event)">Mouse over this paragraph.</p> <script> function getRelatedElement(event) { console.log("The cursor just exited the " + event.relatedTarget.tagName + " element."); } </script>// w ww . java 2 s. c om </body> </html>