HTML oninput event Attribute

❮ HTML Event Attributes


<label for="myInput">Enter your first name:</label> <input type="text" id="myInput" oninput="myFunction()">

<p>You wrote: <output id="demo"></output></p>

function myFunction() {
  var x = document.getElementById("myInput").value;
  document.getElementById("demo").innerHTML = x;


The oninput attribute fires when the value of an element is changed by the user.

Standard Syntax

<element oninput="script">

Browser Support


Attribute Values

Value Description
script Specifies the script to be run on oninput

Technical Details

Supported HTML elements:

<input type="password">, <input type="search">, <input type="text"> and <textarea>
❮ HTML Event Attributes