js中onkeydown回车触发事件的几种方法
documnet文档绑定监听
1 document.onkeydown = function(event){ 2 var e = window.event || event; 3 if (e.keyCode == 13) { 4 //回车执行查询 5 } 6 }
div区域绑定监听
1 $("#queryTable").bind("keydown",function(event){ 2 var e = window.event || event; 3 if (e.keyCode == 13) { 4 //回车执行查询 5 } 6 });
表单控件输入框绑定监听
1 $('#search_input').bind('keyup', function(event) { 2 var e = window.event || event; 3 if (e.keyCode == 13) { 4 //回车执行查询 5 } 6 });