how to stop a button from being fired when press enter
问题 I am using this function to handle enter click on a search textbox but it fires another button in the page, how to stop that button from being fired and call my search() function. InputKeyPress(e) { if (window.event) { if (event.keyCode == 13) { search(); } } else { if (e) { if (e.which == 13) { search(); } } } } 回答1: In the keyCode == 13 case, you need to prevent the default action of the keypress event. The standard way to do this is to call the preventDefault function on the event object