Home > Article > Web Front-end > Detailed explanation and example code of jquery implementation of carriage return login
jquery implements enter login
1. button button submission method
//按钮事件 $(‘#btnSumit‘).click(function() { alert(‘测试‘); }); //回车提交事件 $("body").keydown(function() { if (event.keyCode == "13") {//keyCode=13是回车键 $(‘#btnSumit‘).click(); } });
2. form submission method
a. Use jquery
$("body").bind(‘keyup‘,function(event) { if(event.keyCode==13){ document.form.submit(); } });
b. Non-jquery
<body onkeyup="autosubmit()">//添加监听事件 function autosubmit(){//事件触发函数 if(event.keyCode==13){ document.form.submit(); } }