We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE

Nasi wolontariusze nie przetłumaczyli jeszcze tego artykułu na język Polski. Dołącz do nas i pomóż go przetłumaczyć!
Można także przeczytać artykuł w języku: English (US).

The onblur property returns the onBlur event handler code, if any, that exists on the current element.


element.onblur = function;
  • function is the name of a user-defined function, without the () suffix or any parameters, or an anonymous function declaration, such as
element.onblur = function() { console.log("onblur event detected!"); };



<title>onblur event example</title>

<script type="text/javascript">

var elem = null;

function initElement()
  elem = document.getElementById("foo");
  // NOTE: doEvent(); or doEvent(param); will NOT work here.
  // Must be a reference to a function name, not a function call.
  elem.onblur = doEvent;

function doEvent()
  elem.value = 'Bye-Bye';
  console.log("onblur Event detected!")

<style type="text/css">
#foo {
border: solid blue 2px;

<body onload="initElement();">
<input type="text" id="foo" value="Hello!" />

<p>Click on the above element to give it focus, then click outside the
element.<br /> Reload the page from the NavBar.</p>



The blur event is raised when an element loses focus.

In contrast to MSIE--in which almost all kinds of elements receive the blur event--almost all kinds of elements on Gecko browsers do NOT work with this event.


Specification Status Comment
HTML Living Standard
The definition of 'onblur' in that specification.
Living Standard  

Browser Compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) ? ? ? ?
Feature Android Android Webview Chrome for Android Edge Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? ? ? ? ? ? ?

Autorzy i etykiety dokumentu

 Ostatnia aktualizacja: erikadoyle,