This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

relatedTarget

Summary

Gets the secondary element that is involved in an event. The relatedTarget property is used to find the other element, if any, involved in an event. Events like mouseover are oriented around a certain target, but also involve a secondary target, such as the target that is exited as the mouseover event fires for the primary target.

Property of dom/MouseEventdom/MouseEvent

Syntax

Note: This property is read-only.

var relatedTargetElement = event.relatedTarget;

Return Value

Returns an object of type DOM NodeDOM Node

The secondary element that is involved in an event.

Usage

 Use this property to determine the secondary element that is involved in the event.

The secondary element depends on the type of event:

  • In mouseover events, the secondary element is the element that the mouse pointer left.
  • In mouseout events, the secondary element is the element that the mouse pointer entered.
  • In focusin events, the secondary element is the element that lost focus.
  • In focusout events, the secondary element is the element that gained focus.

Related specifications

DOM Level 3 Events
Working Draft

Attributions