Home javascript Jquery input text change

Jquery input text change

Author

Date

Category

How to track value = "" change in input text in real time in jquery? That is, as soon as the value = "" changed, the alert ($ (this) .val ());


Answer 1, authority 100%

I personally use:

$ (document) .ready (function () {
   $ ('selector'). on ('input', function () {alert ('I didn't google the answer: D')})
 });

But there are several ways, keyup , input , change events. Choose what suits you best.

Google calls it jQuery event or JavaScript event.


Answer 2, authority 12%

For example:

$ ('input'). on ('keyup', function () {
 var $ this = $ (this),
   val = $ this.val ();
 if (val.length & gt; = 1) {
  alert ('the symbol has changed');
 }
}); 
& lt; script src = "https://ajax.googleapis.com/ajax/libs /jquery/1.11.1/jquery.min.js"></script>
& lt; input type = "text" name = "n" id = "n" & gt; 

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions