FocusEvent relatedTarget Property
Definition and Usage
The relatedTarget property returns the element related to the element that triggers the focus/blur event.
- For onfocus and onfocusin event, the related element is the element that loses focus.
- For onblur and onfocusout Event, the related element is the element that gains focus.
This property is read-only.
Example
Get the related element of the element that triggers the onfocus event:
function getRelatedElement(event) { alert(event.relatedTarget.tagName); }
Syntax
event.relatedTarget
Technical Details
Return Value: | Reference to the relevant element, or null if there is no relevant element. |
---|---|
DOM Version: | DOM Level 3 Events |
Browser Support
The numbers in the table indicate the first browser version that fully supports the property.
Properties | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
relatedTarget | Support | 9.0 | 24.0 | Support | Support |