coderef

Focus eventsBaseline · Widely available

Focus events, such as focus and blur, fire when an element gets or loses focus.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jul 29, 2015. Widely available since Jan 29, 2018.

Browser support

DesktopChrome
1+Supportedsince Dec 11, 2008
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1–23Not supported
24+Supportedsince Sep 17, 2013
Current: 157
Safari
1–3Not supported
3.1+Supportedsince Mar 18, 2008
Current: 27
MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155
Firefox Android
4–23Not supported
24+Supportedsince Sep 17, 2013
Current: 157
Safari iOS
1–1Not supported
2+Supportedsince Jul 11, 2008
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: blur event.

Feature detection

JS · check before using
if ("FocusEvent" in globalThis) {
  // FocusEvent is available
} else {
  // load a polyfill or use a fallback
}

Sub-features

Support for each part of the feature (11). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Element.blur_event11263.11862
Element.focus_event112243.118242
Element.focusin_event11252518524.2
Element.focusout_event11252518524.2
FocusEvent261224726247
FocusEvent.FocusEvent261224726247
FocusEvent.relatedTarget261224726247
HTMLElement.blur1121.531841
HTMLElement.focus1121.531841
HTMLElement.focus.options_focusVisible_parameter14514510418.414510418.4
HTMLElement.focus.options_preventScroll_parameter64176815✕✕15.5