HTML oninput Attribute
Example
<label for="myInput">Enter your first name:</label> <input type="text" id="myInput" oninput="myFunction()">
<p>You wrote: <output id="demo"></output></p>
<script>
function myFunction() {
var x = document.getElementById("myInput").value;
document.getElementById("demo").innerHTML = x;
}
</script>
Meaning
The oninput attribute fires when the value of an element is changed by the user.
Standard Syntax
<element oninput="script">
Browser Support
Status
Applies to:
The oninput attribute can be used on the following element:
Element | Attribute |
---|---|
All HTML elements. | oninput |
Attribute Values
Value | Description |
---|---|
script | Specifies the script to be run on oninput |