Javascript DOM oninput Event via HTML Tag oninput function

Introduction

In JavaScript:

object.oninput = function(){
       myScript};

This example uses the HTML DOM to assign an "oninput" event to an input element.

Write something in the text field to trigger a function.

<!DOCTYPE html>/* www  .  j a va 2 s  .c o  m*/
<html>
<body>
Enter name: <input type="text" id="myInput" value="Mickey">
<p id="demo"></p>
<script>
document.getElementById("myInput").oninput = function() {myFunction()};
function myFunction() {
  document.getElementById("demo").innerHTML = "The value of the input field was changed.";
}
</script>

</body>
</html>
MultiLlineTable:
Bubbles:                 Yes
Cancelable:              No
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>



PreviousNext

Related