HTML onblur Attribute
Example
<input type="text" name="fname" id="fname" onblur="myFunction()">
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("fname");
document.getElementById("demo").innerHTML = x.value;
}
</script>
Meaning
The onblur attribute occurs when an element loses focus, meaning that the user has moved focus to another element, typically either by clicking the mouse or by tabbing.
Standard Syntax
<element onblur="script">
Browser Support
Status
Applies to:
The onblur attribute can be used on the following element:
Element | Attribute |
---|---|
All HTML elements | onblur |
Attribute Values
Value | Description |
---|---|
script | Specifies the script to be run on onblur. |