JS判断键盘是否按的回车键并触发指定按钮点击操作

document.onkeydown = function (e) {
            if (!e) e = window.event;
            if ((e.keyCode || e.which) == 13) {
                var obtnLogin = document.getElementById("submit_btn");   //submit_btn为按钮ID
                obtnLogin.focus();
            }
        }

 

posted @ 2017-10-11 14:51  张伟大  阅读(362)  评论(0编辑  收藏  举报