Related Target event properties

Related Target event properties The event object

Definitions and usages

The related Target event property returns the node associated with the target node of the event.

For mouseover events, this property is the node that the mouse pointer leaves when it moves over the target node.

For the mouseout event, the property is the node that the mouse pointer enters when leaving the target.

This property is useless for other types of events.

Grammar

event.relatedTarget

The following example returns the element that the pointer just left:

<! DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
Online tutorials for W3Cschool (w3cschool.cn)
<script>
function getRelatedElement(event){
alert ("Mouse pointer moved to " s event.relatedtarget.tagName s" element");
}
</script>
</head>
<body>

the mouse moves to this segment. </p>

</body>
</html>

Try it out . . .


Related Target event properties The event object