Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
176
rated 0 times [  182] [ 6]  / answers: 1 / hits: 20627  / 9 Years ago, fri, june 12, 2015, 12:00:00

I want to run a function when a HTML <input/> tag changes. How do I do this? There are some answers for this but they are all in jQuery and I want plain javascript. Can someone give me a simple example? Thanks!



I want the input to be a type as text:



<input type=text id=change>

More From » html

 Answers
4

You can use the input event. This will trigger not only on key up and paste, but also other text modification events such as drag & drop.





change.addEventListener(input, function (e) {
alert(this.value);
});

<input type=text id=change>




[#66225] Wednesday, June 10, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mariselas

Total Points: 711
Total Questions: 117
Total Answers: 110

Location: Burkina Faso
Member since Thu, Dec 23, 2021
2 Years ago
;