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();
}
}
精彩评论