Back to Content

FocusEvent: relatedTarget property

files/en-us/web/api/focusevent/relatedtarget/index.md

latest1.8 KB
Original Source

{{APIRef("UI Events")}}

The relatedTarget read-only property of the {{domxref("FocusEvent")}} interface is the secondary target, depending on the type of event:

<table class="no-markdown"> <thead> <tr> <th scope="col">Event name</th> <th scope="col"><code>target</code></th> <th scope="col"><code>relatedTarget</code></th> </tr> </thead> <tbody> <tr> <td>{{domxref("Element/blur_event", "blur")}}</td> <td>The {{domxref("EventTarget")}} losing focus</td> <td>The {{domxref("EventTarget")}} receiving focus (if any).</td> </tr> <tr> <td>{{domxref("Element/focus_event", "focus")}}</td> <td>The {{domxref("EventTarget")}} receiving focus</td> <td>The {{domxref("EventTarget")}} losing focus (if any)</td> </tr> <tr> <td>{{domxref("Element/focusin_event", "focusin")}}</td> <td>The {{domxref("EventTarget")}} receiving focus</td> <td>The {{domxref("EventTarget")}} losing focus (if any)</td> </tr> <tr> <td>{{domxref("Element/focusout_event", "focusout")}}</td> <td>The {{domxref("EventTarget")}} losing focus</td> <td>The {{domxref("EventTarget")}} receiving focus (if any)</td> </tr> </tbody> </table>

Note that many elements can't have focus, which is a common reason for relatedTarget to be null. relatedTarget may also be set to null for security reasons, like when tabbing in or out of a page.

{{domxref("MouseEvent.relatedTarget")}} is a similar property for mouse events.

Value

An instance of {{domxref("EventTarget")}}.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{ domxref("FocusEvent") }}