Web/API/FocusEvent/relatedTarget

From Get docs

The FocusEvent.relatedTarget read-only property is the secondary target, depending on the type of event:

Event name target relatedTarget
blur The EventTarget losing focus The EventTarget receiving focus (if any).
focus The EventTarget receiving focus The EventTarget losing focus (if any)
focusin The EventTarget receiving focus The EventTarget losing focus (if any)
focusout The EventTarget losing focus The EventTarget receiving focus (if any)

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.

MouseEvent.relatedTarget is a similar property for mouse events.

Syntax

secondTarget = focusEvent.relatedTarget

Specifications

Specification Status Comment
UI EventsThe definition of 'FocusEvent.relatedTarget' in that specification. Working Draft
Document Object Model (DOM) Level 3 Events SpecificationThe definition of 'FocusEvent.relatedTarget' in that specification. Obsolete Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

relatedTarget

Experimental'

Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support 48

IE

Full support 9

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 48

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support Yes

Legend

Full support  
Full support
Experimental. Expect behavior to change in the future.'
Experimental. Expect behavior to change in the future.


See also