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

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

注意, many elements can't have focus , which is a common reason for relatedTarget 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.

句法

secondTarget = focusEvent.relatedTarget
					

规范

规范 状态 注释
UI Events
The definition of 'FocusEvent.relatedTarget' in that specification.
工作草案
DOM (文档对象模型) 3 级事件规范
The definition of 'FocusEvent.relatedTarget' in that specification.
过时 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
relatedTarget Chrome Yes Edge 12 Firefox 48 IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 48 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持

完整支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

另请参阅

元数据

  • 最后修改: