keyup on textfields
|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
keyup on textfieldsHi,
Im new in jQuery, so... I need the textfields triggers the same function and I have a lot of them, Im doing this way: $('#id_emp').keyup(function(e) { if (e.keyCode == 13) { $('#busca').click(); } }); $('#id_bol').keyup(function(e) { if (e.keyCode == 13) { $('#busca').click(); } }); $('#ema_pes').keyup(function(e) { if (e.keyCode == 13) { $('#busca').click(); } }); $('#nom_emp').keyup(function(e) { if (e.keyCode == 13) { $('#busca').click(); } }); But Im think that have a better way to do this, like: $('ALL_TEXTFIELDS').keyup(function(e) { if (e.keyCode == 13) { $('#busca').click(); } }); There's something like this? tks |
|
|
Re: keyup on textfieldsThere are a few simple ways to do this.
Here are probably the most common: You can assign all the relevant textfields with the same class name: <input type="text name="text1" class="specialFields" /> <input type="text name="text2" class="specialFields" /> $(".specialFields").keyup(...); Or you can list all the IDs in the selector: $("#id_emp, #id_bol, #ema_pes, #nom_emp").keyup(...); On Oct 30, 7:12 am, onaiggac <denisribe...@...> wrote: > Hi, > Im new in jQuery, so... > > I need the textfields triggers the same function and I have a lot of > them, Im doing this way: > > $('#id_emp').keyup(function(e) { > if (e.keyCode == 13) { > $('#busca').click(); > } > }); > > $('#id_bol').keyup(function(e) { > if (e.keyCode == 13) { > $('#busca').click(); > } > }); > > $('#ema_pes').keyup(function(e) { > if (e.keyCode == 13) { > $('#busca').click(); > } > }); > > $('#nom_emp').keyup(function(e) { > if (e.keyCode == 13) { > $('#busca').click(); > } > }); > > But Im think that have a better way to do this, like: > > $('ALL_TEXTFIELDS').keyup(function(e) { > if (e.keyCode == 13) { > $('#busca').click(); > } > }); > > There's something like this? > > tks |
|
|
Re: Re: keyup on textfieldsTks James,
You help me to write a clean code. |
|
|
Re: Re: keyup on textfieldsOr, if the OP really wants all text fields to trigger it, he could just use $(':text').keyup( ... )
--Karl ____________ Karl Swedberg On Oct 30, 2009, at 3:20 PM, James wrote:
|
|
|
Re: Re: keyup on textfieldsActually, I need only 4 text fields to trigger the function and I have 10. :)
But tks for the hint. |
| Free embeddable forum powered by Nabble | Forum Help |