0

我需要你对我的 jQuery 多重绑定的建议。我想添加 2 个绑定,1 个用于 #button_sign_in,1 个用于 #button_sign_up

这是 #button_sign_in 的代码:

$(document).bind('keypress', function(e) {
    if (e.keyCode == 13) {
        $('#button_sign_in').trigger('click');
    }
});

这是#button_sign_up的代码

$(document).bind('keypress', function(e) {
    if (e.keyCode == 13) {
        $('#button_sign_up').trigger('click');
    }
});

我尝试使用该代码,但只需#button_sign_in使用输入键即可。#button_sign_up没用。

4

1 回答 1

0

试试这个

//give input class to all your form control
$('.input','#button_sign_in').keypress(function (e) {
  if (e.which == 13) {
   $('form#button_sign_in').submit();
  }
});

并遵循相同的注册表单

于 2013-07-12T06:55:05.577 回答