addEventListener("input", myFunction); - Javascript DOM Event

Javascript examples for DOM Event:addEventListener

Description

The oninput event occurs when an element gets user input.

Summary

Bubbles Yes
Cancelable No
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>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

Enter name: <input type="text" id="myInput" value="Mickey">

<script>
document.getElementById("myInput").addEventListener("input", myFunction);

function myFunction() {//w w w  .  java2s  .c om
    console.log("The value of the input field was changed.");
}
</script>

</body>
</html>

Related Tutorials