javascript - Check input when text is changed -
I have a question about when input text should be replaced, I use this as the but the actual value is There are 3 ways to apply it. The first is using the other events like The other way is to and the last time using keydown :
$ ('# query'). Keydown (function () {console.log ($ (this) .val ());});
query , then the console log will be
quer . This is always a delay, I do not know why?
input or
propertychange . Note that
propertychange is only supported on IE and
input is supported on modern browsers.
$ ('# query'). 'Input perpertychange', function () {console.log ($ (this) .val ());});
console.log ($ (this) .val ()); in
setTimeout statement. You can get what you are typing. (Reason? I'm sorry, I do not really know why, use it);
$ ('# query'). Keydown (function () {var query = $ (this); settimeout (function () {console.log (query.val ());}, 0);});
textchange events like this:
$ ('# query'). ('Textchange', function () {console.log ($ (this) .val ());});
Comments
Post a Comment