Свойство onblur
из GlobalEventHandlers
событий EventHandler
для blur
события. Оно доступно дляElement
, Document
и Window
.
Событие blur
возникает когда элемент теряет фокус.
Note: Обратным onblur
является onfocus
.
Syntax
target.onblur = functionRef;
Value
functionRef
- это имя функции или function expression. Функция получает объект FocusEvent
в качестве единственного аргумента.
Example
HTML
<input type="text" value="CLICK HERE">
JavaScript
let input = document.querySelector('input');
input.onblur = inputBlur;
input.onfocus = inputFocus;
function inputBlur() {
input.value = 'Focus has been lost';
}
function inputFocus() {
input.value = 'Focus is here';
}
Result
Нажимайте внутри и вне поля формы. Содержимое будет изменятся.
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard Определение 'onblur' в этой спецификации. |
Живой стандарт |
Browser compatibility
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
In contrast to IE, in which almost all kinds of elements receive the blur
event, only a few kinds of elements on Gecko browsers work with this event.
See also
blur
event- Related event handler:
GlobalEventHandlers.onfocus