The input event fires when the value of an <input>, <select>, or <textarea> element has been changed. 

Bubbles Yes
Cancelable No
Interface InputEvent
Target Element
Default Action None
Event handler property GlobalEventHandlers.oninput

The event also applies to elements with contenteditable enabled, and to any element when designMode is turned on. In the case of contenteditable and designMode, the event target is the editing host. If these properties apply to multiple elements, the editing host is the nearest ancestor element whose parent isn't editable.

For <input> elements with type=checkbox or type=radio, the input event should fire whenever a user toggles the control, per the HTML5 specification. However, historically this has not always been the case. Check compatibility, or use the change event instead for elements of these types.

Note: Unlike input, the change event is not necessarily fired for each alteration to an element's value.

Examples

This example logs the value whenever you change the value of the <input> element.

HTML

<input placeholder="Enter some text" name="name"/>
<p id="values"></p>

JavaScript

const input = document.querySelector('input');
const log = document.getElementById('values');

input.addEventListener('input', updateValue);

function updateValue(e) {
  log.textContent = e.srcElement.value;
}

Result

Specifications

Specification Status
HTML Living Standard
The definition of 'input event' in that specification.
Living Standard
Document Object Model (DOM) Level 3 Events Specification
The definition of 'input event' in that specification.
Obsolete

Browser compatibility

No compatibility data found. Please contribute data for "api.HTMLElement.input" (depth: 1) to the MDN compatibility data repository.

See also