VOOZH about

URL: https://www.geeksforgeeks.org/html/html-dom-inputevent/

⇱ HTML DOM InputEvent - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML DOM InputEvent

Last Updated : 3 Oct, 2024

The input event is fired when the user changes an element, the value of an element or <textarea> element. DOM InputEvent occurs when an element in the HTML document gets input from the user.

InputEvent property:

  • data: Returns the inserted characters.
  • dataTransfer: Returns an object containing information about the inserted/deleted data.
  • getTargetRanges: Returns an array containing target ranges that will be affected by the insertion/.eletion.
  • inputType: Returns the type of the change (i.e "inserting" or "deleting")
  • isComposing: Returns the state of the event.

Syntax:

<element oninput="Function">

Example 1: Accessing input type using "event.inputType;"

Output:

👁 inputType
Input Type

Example-2: Accessing data property to return inserted characters.

Output:

👁 Image
input character

Example-3: In this example, oninput return the whole inserted data.

Output:

👁 inputWords
input event inserted data


Supported Browsers:

  • Google Chrome 1
  • Mozilla Firefox 4.0
  • Internet Explorer 9.0
  • Safari 5.0
  • Opera 11.6
Comment
Article Tags: