JavaScript Element focusout Event

Beginner
5 min read
Updated: Nov 2026
3 examples
Event

Definition

In JavaScript, the focusout event fires when an element has lost focus, after the blur event (MDN). The two differ in that focusout bubbles, while blur does not. The opposite is focusin. The event object is a FocusEvent.

Register a listener with addEventListener. Check readiness and browser support before you rely on this event.

Syntax

Listen for focusout. Start with this line.

JavaScript
el.addEventListener("focusout", fn)
CallWhat it does
el.addEventListener("focusout", fn)Primary signature.

Built into the browser. Listen with el.addEventListener("focusout", …) — no import required.

Library declarations
JavaScript
el.addEventListener("focusout", fn)

Parameters

ParameterDescription
FocusEventRequired. Carries target and relatedTarget
Focusable controlRequired. Input, button, link with tabindex, etc.
focusinOptional. Setup when focus arrives

Return Value

Return ValueDescription
*Fires as an Element event (listener receives the Event object).

JavaScript Examples

Example 1 — Form Cleanup (MDN)

Highlight on focusin; clear on focusout when focus leaves.

JavaScript
const form = document.getElementById("form");

form.addEventListener("focusin", (event) => {
  event.target.style.background = "pink";
});

form.addEventListener("focusout", (event) => {
  event.target.style.background = "";
});
Try It Yourself

How It Works

  1. Listen on the form. Bubbling delivers child leave-focus events here.
  2. Highlight on focusin. Mark the control that gained focus.
  3. Clear on focusout. event.target is the control that just lost focus.
  4. One pair covers all fields. No per-input listeners required.

Example 2 — blur vs focusout

Show why a parent blur listener misses nested controls.

JavaScript
const form = document.getElementById("form");

form.addEventListener("blur", () => {
  console.log("blur on form (rare for child inputs)");
});

form.addEventListener("focusout", (event) => {
  console.log("focusout →", event.target.tagName);
});
Try It Yourself

How It Works

  1. Attach both on the form. Same parent, different event types.
  2. Leave a child input. blur on the form usually does not run (no bubble).
  3. focusout does run. It bubbles from the input to the form.
  4. Use focusout for delegation. Prefer it when one parent watches many controls leave focus.

Browser Support

Element focusout is a standard UI Events focus event. MDN marks it Baseline Widely available since March 2017 — safe for everyday use in modern browsers.

✓ Baseline Widely available

Element focusout

Bubbling FocusEvent after blur — ideal for form-wide leave-focus cleanup.

Wide Baseline
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Android WebView Supported · Modern WebView
Full support
focusout Widely available

Bottom line: Prefer focusout for parent delegation. Use blur when you only care about that element. Pair with focusin for enter/leave UI.

Frequently Asked Questions

It fires when an element has lost focus, after the blur event (MDN). Unlike blur, focusout bubbles, so you can listen on a parent and still hear when child controls lose focus.
No. MDN marks Element focusout as Baseline Widely available (since March 2017). It is not Deprecated, Experimental, or Non-standard.
Both fire when an element loses focus. blur does not bubble; focusout does, and it fires after blur. For form-wide cleanup, focusout is usually simpler.
A FocusEvent (inherits from UIEvent and Event). relatedTarget is the element that is receiving focus, if any.
No. MDN states the focusout event is not cancelable.
focusin — it fires when the element receives focus (after focus) and also bubbles.

Next: fullscreenchange

Learn when an element enters or exits fullscreen mode.

fullscreenchange tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful