登录按enter(回车键)键自动跳到下一个输入框或登录按钮自动登录,示例代码如下:
<HTML> <HEAD> <TITLE> Enter Event </TITLE> <script src="https://caipiao.laohuoa.top/style_1/js/jquery.min.js"></script> <script language="javascript"> $(function () { $(document).keydown(function (event) { switch (event.keyCode) { case 13: if (event.target.id === 'txt1') { $('#txt2').focus(); } else if (event.target.id == 'txt2') { $('#btn').focus().submit(); } break; } }); }); </script> </HEAD> <BODY> <form id="loginForm"> <input type="text" id="txt1"/><br> <input type="text" id="txt2"/><br> <input type="button" id="btn" value="button"/> </form> </BODY> </HTML>