relatedTarget Event Property | Tutorial
Definition and Usage
The relatedTarget event property returns the node related to the event's target node.
For the mouseover event, this property is the node that the mouse pointer left when it moved onto the target node.
For the mouseout event, this property is the node that the mouse pointer entered when it left the target.
For other types of events, this property is not useful.
Syntax
event.relatedTarget
Example
The following example returns the element the pointer just left:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial(example.com)</title>
<script>
function getRelatedElement(event){
alert("The mouse pointer moved to " + event.relatedTarget.tagName + " element");
}
</script>
</head>
<body>
<p onmouseover="getRelatedElement(event)">Move the mouse over this paragraph.</p>
</body>
</html>
YouTip