开发者

Detecting keydown event with jQuery in ASP.NET

In my project, there is a button search which seems to be the default button to trigger when th开发者_如何学运维e ENTER key has been pressed.

How can I detect a keydown event with jQuery for a login button?

It's an ASP.NET project.


Bind the "keypress" event handler to an element using jQuery.

See .keyPress() in the jQuery API.

Example code:

$('#login_button_id').keypress(function(event) {
  //prevent submission when enter key pressed
  if (event.keyCode == '13') {
    event.preventDefault();
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜