The DOM input
event is fired synchronously when the value of an <input>
, <select>
, or <textarea>
element is changed. (For input
elements with type=checkbox
or type=radio
, the input
event does not fire when a user clicks the control, because the value
attribute does not change.) Additionally, it fires on contenteditable
editors when its contents are changed. In this case, the event target is the editing host element. If there are two or more elements which have contenteditable
as true, "editing host" is the nearest ancestor element whose parent isn't editable. Similarly, it's also fired on root element of designMode
editors.
General info
- Specification
- HTML5, DOM Level 3 Events
- Interface
Event
,InputEvent
- Bubbles
- Yes
- Cancelable
- No
- Target
- Element
- Default Action
- The value or the content is modified.
Properties
Property | Type | Description |
---|---|---|
target Read only |
EventTarget |
The event target (the topmost target in the DOM tree). |
type Read only |
DOMString |
The type of event. |
bubbles Read only |
Boolean |
Whether the event normally bubbles or not |
cancelable Read only |
Boolean |
Whether the event is cancellable or not? |
Browser compatibility
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes)[1] | 9[2][3] | (Yes)[4] | (Yes) |
immediately after compositionupdate |
(Yes) | (Yes) | 12 (12) | (Yes) | 15 | (Yes) |
on contenteditable element |
(Yes) | (Yes) | 14 (14) | No support[5]
|
15 | (Yes) |
when designMode is "on" |
(Yes) | ? | 14 (14) | No support | 15 | (Yes) |
data |
? | ? | No support | ? | ? | ? |
isComposing |
No support | ? | 31 (31) | No support | No support | No support |
<select> | (Yes) | No support | 49 (49) | No support | ? | ? |
Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | ? | ? | (Yes) |
immediately after compositionupdate |
? | ? | (Yes) | 12.0 (12) | ? | ? | ? |
on contenteditable element |
? | (Yes) | ? | 14.0 (14) | ? | ? | (Yes) |
when designMode is "on" |
? | ? | ? | 14.0 (14) | ? | ? | ? |
data |
? | ? | ? | No support | ? | ? | ? |
isComposing |
No support | No support | ? | 31.0 (31) | No support | No support | No support |
<select> | ? | (Yes) | ? | No support | ? | ? | ? |
[1] Prior to Gecko 12.0 (Firefox 12.0 / Thunderbird 12.0 / SeaMonkey 2.9), Gecko didn't fire input events while composition was ongoing using IMEs or when dead keys were used on Mac OS X.
[2] IE 9 does not fire an input event when the user deletes characters from an input (e.g. by pressing Backspace or Delete, or using the "Cut" operation).
[3] IE 10 and 11 has a bug, input event fires on placeholder attribute changes.
[4] Prior to Opera 15, Opera did not fire an input event after dropping text in an input field.
[5] The event target is the innermost element at the caret position.
See also
Also the change
event is related. change
fires less often than input
– it only fires when the changes are committed by the user.