oninput event
Definition and usage
The oninput event occurs when the element receives user input.
This event occurs when the value of an <input> or <textarea> element changes.
Tip:This event is similar to onchange Είδος Ειδήσεων. The difference is that the oninput event occurs immediately after the element value changes, while onchange occurs when the element loses focus and the content changes. Another difference is that the onchange event also applies to <select> elements.
Instance
Example 1
Execute JavaScript when the user writes content in the <input> field:
<input type="text" oninput="myFunction()">
Example 2
Range slider - how to dynamically update the slider value:
<input type="range" oninput="myFunction(this.value)">
Syntax
In HTML:
<element oninput="myScript">
In JavaScript:
object.oninput = function(){myScript};
In JavaScript, use the addEventListener() method:
object.addEventListener("input", myScript);
Note:Internet Explorer 8 or earlier versions do not support addEventListener() method.
Technical details
Bubbling: | Υποστήριξη |
---|---|
Cancellable: | Not supported |
Event type: | Event, InputEvent |
Supported HTML tags: | <input type="color">, <input type="date">, <input type="datetime">, <input type="email">, <input type="month">, <input type="number">, <input type="password">, <input type="range">, <input type="search">, <input type="tel">, <input type="text">, <input type="time">, <input type="url">, <input type="week"> and <textarea> |
DOM version: | Level 3 Είδη Ειδήσεων |
Υποστήριξη Προγράμματος Περιήγησης
Τα αριθμήματα στη διάταξη σηματοδοτούν την πρώτη έκδοση του προγράμματος περιήγησης που υποστηρίζει πλήρως το γεγονός.
Είδη Ειδήσεων | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
oninput | Υποστήριξη | 9.0 | 4.0 | 5.0 | Υποστήριξη |