Favorites

DOM HTMLElement: input event

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
HTMLElement: input event
DOM HTMLElement EventThis event is supported by all modern browsers.
Updated 28th November 2026

The input event fires every time the value of an input, textarea, select or contenteditable element changes.

Description

The input event fires every time the value changes in an <input>, <select> or <textarea>, or in an element with contenteditable. It covers typing, pasting, dragging text, autofill and voice input, which makes it better than keyboard events for live features like search-as-you-type and character counters. It bubbles, so one listener on a form can handle every field.

The event object is an InputEvent for text fields, with inputType describing what happened, such as "insertText" or "deleteContentBackward", and data containing the inserted text. For checkboxes and selects, the value change is immediate, so input and change fire together.

For live searches that send requests, combine the input event with a short debounce using setTimeout(), so a request is only made once the user pauses typing. It bubbles, so a single listener on a common ancestor, such as a form or the document, can handle it for many elements, using event.target to tell them apart.

Syntax

element.addEventListener('input', handler)

Example

<textarea id="msg" maxlength="100" rows="3"></textarea>
<p id="count">0 / 100</p>
const msg = document.getElementById('msg');
const count = document.getElementById('count');
msg.addEventListener('input', () => {
  count.textContent = `${msg.value.length} / 100`;
});
console.log('Type in the box');

Browser Support

The following information will show you the current browser support for the HTMLElement: input event event. Hover over a browser icon to see the version that first introduced support for this event.

This event is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee