This feature is not Baseline because it does not work in some of the most widely-used browsers.
The focusout event fires when an element has lost focus, after the blur event. The two events differ in that focusout bubbles, while blur does not.
The opposite of focusout is the focusin event, which fires when the element has received focus.
The focusout event is not cancelable.
Use the event name in methods like addEventListener().
addEventListener("focusout", (event) => { })
Note: There is no onfocusout event handler property for this event.
A FocusEvent. Inherits from UIEvent and Event.
This interface also inherits properties from its parent UIEvent, and indirectly from Event.
The element receiving focus, if any.
<form id="form">
<label>
Some text:
<input type="text" placeholder="text input" />
</label>
<label>
Password:
<input type="password" placeholder="password" />
</label>
</form>
const form = document.getElementById("form");
form.addEventListener("focusin", (event) => {
event.target.style.background = "pink";
});
form.addEventListener("focusout", (event) => {
event.target.style.background = "";
});
| Specification |
|---|
| UI Events> # event-type-focusout> |
Note: The UI Events specification describes an order of focus events that's different from what current browsers implement.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
focusout_event |
1Theonfocusout event handler property is not supported. To listen to this event, use element.addEventListener('focusout', function() {});. |
12Theonfocusout event handler property is not supported. To listen to this event, use element.addEventListener('focusout', function() {});. |
52Theonfocusout event handler property is not supported. To listen to this event, use element.addEventListener('focusout', function() {});. |
11.6 | 5 | 18Theonfocusout event handler property is not supported. To listen to this event, use element.addEventListener('focusout', function() {});. |
52Theonfocusout event handler property is not supported. To listen to this event, use element.addEventListener('focusout', function() {});. |
12.1 | 4.2 | 1.0Theonfocusout event handler property is not supported. To listen to this event, use element.addEventListener('focusout', function() {});. |
4.4Theonfocusout event handler property is not supported. To listen to this event, use element.addEventListener('focusout', function() {});. |
4.2 |
blur, focus, focusin
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Element/focusout_event