The oninput
attribute event is triggered
when the value of an <input> or <textarea> element is changed.
The oninput
attribute event is similar to
the onchange
event.
The oninput
event
occurs immediately after the value of an element has changed.
The onchange
event occurs when the element loses focus.
The onchange event also works on <select> elements.
The oninput
attribute is new in HTML5.
<element oninput="script or Javascript function name">
<input type="password">, <input type="search">, <input type="text"> <textarea>
oninput |
Yes | Yes | Yes | Yes | Yes |
<!DOCTYPE html>
<html>
<body>
<!--from ww w . j a va2s . co m-->
<input type="text" id="myInput" oninput="myFunction()">
<script>
function myFunction() {
var x = document.getElementById("myInput").value;
console.log(x);
}
</script>
</body>
</html>