GlobalEventHandlers.onblur
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Свойство onblur
из GlobalEventHandlers
событий event handler
для blur
события. Оно доступно дляElement
, Document
и Window
.
Событие blur
возникает когда элемент теряет фокус.
Примечание:
Обратным 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
Нажимайте внутри и вне поля формы. Содержимое будет изменятся.
Спецификации
Specification |
---|
UI Events # event-type-blur |
HTML # handler-onblur |
Совместимость с браузерами
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
blur event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
Смотрите также
- Событие
blur
- Related event handler:
GlobalEventHandlers.onfocus