HTML onchange event Attribute
Example
<input type="text" name="fname" id="fname" onchange="myFunction()">
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("fname");
document.getElementById("demo").innerHTML = x.value;
}
</script>
Meaning
The onchange attribute fires when the form control has lost user focus and its value has been modified during its last access.
Standard Syntax
<element onchange="script">
Browser Support
Status
Attribute Values
Value | Description |
---|---|
script | Specifies the script to be run on onchange |
Technical Details
Supported HTML elements:
<input type="checkbox">, <input type="file">, <input type="password">, <input type="radio">, <input type="range">, <input type="search">, <input type="text">, <select> and <textarea>