开发者

Detecting keydown event with jQuery in ASP.NET

开发者 https://www.devze.com 2023-01-17 06:52 出处:网络
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.

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

精彩评论

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