在jQuery中检测input [type = text]的值更改 [英] Detecting value change of input[type=text] in jQuery
本文介绍了在jQuery中检测input [type = text]的值更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望每次特定输入框的值更改时都执行一个函数.它几乎与$('input').keyup(function)
一起使用,但是例如在将文本粘贴到框中时什么也不会发生. $input.change(function)
仅在输入模糊时才触发,那么每当文本框更改值时我如何立即知道?
I want to execute a function every time the value of a specific input box changes. It almost works with $('input').keyup(function)
, but nothing happens when pasting text into the box, for example. $input.change(function)
only triggers when the input is blurred, so how would I immediately know whenever a text box has changed value?
推荐答案
只是建议在"bind"函数上建议使用"on",因此请始终尝试使用这样的事件侦听器:
just remenber that 'on' is recomended over the 'bind' function, so always try to use a event listener like this:
$("#myTextBox").on("change paste keyup", function() {
alert($(this).val());
});
这篇关于在jQuery中检测input [type = text]的值更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文