relatedTarget property (event)
Returns a reference to the related element in case of onmouseover, onmouseout, dragenter and dragexit events.
- in case of onmouseover event, the relatedTarget property retrieves the element that the mouse pointer left,
- and in case of onmouseout event, the relatedTarget property retrieves the element that the mouse pointer entered.
The fromElement, toElement and relatedTarget properties can only be used for activation and mouse move events. In general, if you need the object on which an event occurred, use the target and srcElement properties. If you need the element on which the event listener was registered, use the currentTarget property.
You can find the related objects in the Supported by objects section below.
This property is read-only.
Retrieves a reference to the related element.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the relatedTarget property:
Did you find this example helpful?
User Contributed Comments