FocusEvent relatedTarget Property
Example
Get the related element of the element that triggered an onfocus event:
function getRelatedElement(event) {
alert(event.relatedTarget.tagName);
}
Try it yourself »
Definition and Usage
The relatedTarget property returns the element related to the element that triggered the focus/blur event.
- For onfocus and onfocusin events, the related element is the element that LOST focus.
- For onblur and onfocusout events, the related element is the element that GOT focus.
This property is read-only.
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
relatedTarget | Yes | 9.0 | 24.0 | Yes | Yes |
Syntax
event.relatedTarget
Technical Details
Return Value: | A reference to the related element, or null if there is no related element |
---|---|
DOM Version: | DOM Level 3 Events |
Event Object