html tutorial - oninput Attribute in HTML - html5 - html code - html form
Learn html - html tutorial - Oninput attribute in html - html examples - html programs
- The oninput attribute triggers an event when a user enters the input in the input field.
- The oninput attribute triggers when the value of an <input> or <textarea> element is changed.
Syntax for oninput attribute in HTML:
Difference between HTML 4.01 and HTML 5 for oninput Attribute:
- HTML 4 does not support oninput attribute.
- The oninput attribute is new in HTML5.
|All HTML Elements||oninput|
oninput Attribute Value:
|script||The script to be run on oninput.|
Sample Coding for oninput Attribute in HTML:
Code Explanation for oninput Attribute in HTML:
- Get the value from <input> tag which has id value as “tutorial” and stored in variable a.
- The innereHTML text of element which has id as “paraid” will be changed to “The text is:” and concatenate with value of “a” variable.
Output for oninput Attribute in HTML:
- The output shows the text box is displayed on page load.
- When the user start to type anything in the text box that will be displayed on bottom of the textbox.
Browser Support for oninput Attribute in HTML:
Tips and Notes
- The oninput attribute is like to the onchange event.
- The difference is which the oninput event shows suddenly after the value of an element has changed, although onchange event shows when the element drops focus.