Is it possible to bind keyup()
to an entire <form>
? For example, I have multiple <input type="text">
fields inside a form, and I want to bind a keyup
event to all of them without having to attach a keyup
event handler to each one. Rather, I want to bind one keyup
event handler to all of them so if any of the text fields detect a keyup
event, the event handler will run. Is this possible in jQuery?
I tried:
$('form').keyup(function() {...});
But that made the keyup event handler fire indefinitely after typing one character.
I don't think this is possible, but you are able to bind the same keyup
event to all the inputs at once:
$('#myform input[type=text]').on('keyup', /* yada */);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With