EN
JavaScript - how can I set ontype event on input text element?
1 answers
5 points
After checking MDN Documentation I have noticed there is no ontype
event for <input type="text">
element.
I don't want to use onchange
event.
Is there some way how to handle event always on text change?
1 answer
6 points
You should use oninput
event.
e.g.
xxxxxxxxxx
1
<input type="text" oninput="console.log(this.value)" />
OR:
xxxxxxxxxx
1
<input id="element" type="text" />
2
<script>
3
4
var element = document.querySelector('#element');
5
6
element.addEventListener('input', function() {
7
console.log(element.value);
8
});
9
10
</script>
0 commentsShow commentsAdd comment