Easy Tutorial
❮ Jsref Match Prop Element Classlist ❯

relatedTarget Event Property


Definition and Usage

The relatedTarget event property returns the node related to the target node of the event.

For the mouseover event, this property is the node the mouse pointer left when moving onto the target node.

For the mouseout event, this property is the node the mouse pointer entered when leaving the target.

This property is not useful for other types of events.

Syntax


Example

Example

The following example returns the element the pointer just left:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</title>
<script>
function getRelatedElement(event){ 
    alert("Mouse pointer moved to " + event.relatedTarget.tagName + " element");
}
</script>
</head>
<body>

<p onmouseover="getRelatedElement(event)">Move the mouse over this paragraph.</p>

</body>
</html>

❮ Jsref Match Prop Element Classlist ❯