The FocusEvent
interface represents focus-related events, including focus
, blur
, focusin
, and focusout
.
The FocusEvent
interface represents focus-related events, including focus
, blur
, focusin
, and focusout
.
FocusEvent()
Creates a FocusEvent
event with the given parameters.
This interface also inherits properties from its parent UIEvent
, and indirectly from Event
.
An EventTarget
representing a secondary target for this event. In some cases (such as when tabbing in or out a page), this property may be set to null
for security reasons.
This interface has no specific methods. It inherits methods from its parent UIEvent
, and indirectly from Event
.
The UI Events specification states that focus events occur in a set order relative to one another, and goes on to describe the typical sequence of events that fire when the focus is shifted from element A to element B:
focusout
: sent before element A loses focus.focusin
: sent before element B receives focus.blur
: sent after element A loses focus.focus
: sent after element B receives focus.However, current browser implementations fire these four events in a different order:
blur
: sent after element A loses focus.focusout
: sent after the blur
event.focus
: sent after element B receives focus.focusin
: sent after the focus
event.Specification |
---|
UI Events # interface-focusevent |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
FocusEvent |
26 | 12 | 24 | No | 15 | 7 | 4.4 | 26 | 24 | 14 | 7 | 1.5 |
FocusEvent |
26 | 12 | 24 | 9 | 15 | 7 | 4.4 | 26 | 24 | 14 | 7 | 1.5 |
relatedTarget |
26 | 12 | 24 | 9 | 15 | 7 | 4.4 | 26 | 24 | 14 | 7 | 1.5 |
Event
base interface
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent