简体   繁体   中英

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.

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. 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 . After removing the .unbind everything worked. Thanks for all the help!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM