relatedTargetEvent Property
Event ObjectDefinition 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 moving onto the target node.
For the mouseout event, this property is the node that the mouse pointer entered when leaving the target.
For other types of events, this property is not useful.
Syntax
event.relatedTarget
Example
Example
The following example returns the element that the pointer just left:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie 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>
<html>
<head>
<meta charset="utf-8">
<title>Rookie 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>
Try it Yourself »
Event Objectother extensions