简体   繁体   中英

Prevent the click event while press the enter key when button in focus in Jquery

Please advise me, i created a form and press tab key to focus the button. If i press the enter key instead of mouse click event, then jquery events triggers the both keypress and click event. So how can i prevent the click event.

please try this one :

$("#ButtonID").keypress(function(e){
   if(e.keyCode === 13){
       e.preventDefault();
   }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM