GlobalEventHandlers.onblur
Свойство onblur
из GlobalEventHandlers
событий EventHandler
(en-US) для blur (en-US)
события. Оно доступно дляElement
, Document
и Window
.
Событие blur
возникает когда элемент теряет фокус.
Note: Обратным onblur
является onfocus
.
Syntax
target.onblur = functionRef;
Value
functionRef
- это имя функции или function expression. Функция получает объект FocusEvent
(en-US) в качестве единственного аргумента.
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
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 (en-US)
event- Related event handler:
GlobalEventHandlers.onfocus