How to capture enter key being pressed on pages containing multiple forms?

后端 未结 4 1026
既然无缘
既然无缘 2021-01-31 20:57

I have inherited a web application where the usual ability to press return in any of the input fields has been disabled for the very good reason that the page contains multiple

4条回答
  •  不思量自难忘°
    2021-01-31 21:25

    You can bind key press event for Enter key in jquery :

    $("form").bind("keypress", function(e) {
       if (e.keyCode == 13) {
          your_custom_submit_function();
          return false; // ignore the default event
       }
    });
    

提交回复
热议问题