Friday, October 30, 2009

[jQuery] keyup on textfields

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

No comments: