I volontari di MDN non hanno ancora tradotto questo articolo in Italiano. Unisciti a noi e traducilo tu stesso.
Puoi anche consultare l’articolo in English (US).

The DOM input event fires synchronously when the value of an <input>, <select>, or <textarea> element has been altered. 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.

General info

Interface InputEvent
Sync / Async Sync
Bubbles Yes
Cancelable No
Composed Yes
Target Element
Default Action None

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.

Specifications

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

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 15 (Yes)
when designMode is "on" (Yes) ? 14 (14) No support 15 (Yes)
data (Yes) ? No support ? ? (Yes)
isComposing (Yes) ? 31 (31) No support No support No support
on <select> element (Yes) No support 49 (49) No support ? ?
on <input> element of type checkbox (Yes) ? 49 (49) No support (Yes) No support
on <input> element of type radio (Yes) ? 49 (49) No support (Yes) 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
on <select> element ? (Yes) ? No support ? ? ?
on <input> element of type checkbox ? ? ? ? ? ? ?
on <input> element of type radio ? ? ? ? ? ? ?

[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 macOS 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 IE 11 have a bug where the 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.

See also

Tag del documento e collaboratori

Ultima modifica di: mfluehr,