Get the related element of the element that triggered an onfocus event:
function getRelatedElement(event) {
alert(event.relatedTarget.tagName);
}
Try it Yourself »
The relatedTarget property returns the element related to the element that triggered the focus/blur event.
This property is read-only.
event.relatedTarget
Return Value: | A reference to the related element, or null if there is no related element |
---|---|
DOM Version: | DOM Level 3 Events |
event.relatedTarget
is a DOM Level 3 (2004) feature.
It is fully supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!