[英]JQuery .change works but .keyup does not
I am trying to bind some functions to some input fields. 我试图将某些功能绑定到某些输入字段。 The weird part is, if I add the .change
event to the inputs it fires just fine but when I add the '.keyup' on the same inputs the event does not fire. 奇怪的是,如果我将.change
事件添加到输入中,则可以正常触发,但是当我在相同的输入上添加“ .keyup”时,则不会触发该事件。
Note: Yes the inputs are found in a document ready function. 注意:是,可以在文档就绪功能中找到输入。 I also commented out the .unbind
method and that did not fix the issue. 我还注释掉了.unbind
方法,但没有解决问题。 The only reason that is there is so I can call the this method later and the inputs will not be bound twice. 唯一的原因是这样,我以后可以调用此方法,并且输入不会被绑定两次。
here is what I am using: 这是我正在使用的:
bindInputChange: function()
{
var inputs = jQuery(':input');
if(inputs != null)
{
inputs.unbind();
}
inputs.change(function() { alert('change called'); }); // this one works
inputs.keyup(function() { alert('keyup called'); }); // this one does not
},
any ideas? 有任何想法吗? Thanks! 谢谢!
It turns out that I have another function that makes anything you type uppercase and that function has an .unbind
which was removing the .keyup
. 事实证明,我还有另一个函数可以使您键入的所有内容都大写,并且该函数具有一个.unbind
,它会删除.keyup
。 After removing the .unbind
everything worked. 删除.unbind
一切正常。 Thanks for all the help! 感谢您的所有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.