JS is a method for judging whether the keyboard presses the enter key and triggering the designated button click operation
- 2021-07-21 06:40:58
- OfStack
Examples are as follows:
document.onkeydown = function (e) {
if (!e) e = window.event;
if ((e.keyCode || e.which) == 13) {
var obtnLogin = document.getElementById("submit_btn"); //submit_btn For buttons ID
obtnLogin.focus(); fun();// Method triggered by submit button
}
}