There 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...@gmail.com> 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

Reply via email to