JS监听某个输入框
1 //回车事件绑定 2 $('#search_input').bind('keyup', function(event) { 3 if (event.keyCode == "13") { 4 //回车执行查询 5 $('#search_button').click(); 6 } 7 });
JS监听某个DIV区域
1 $("#queryTable").bind("keydown",function(e){ 2 // 兼容FF和IE和Opera 3 var theEvent = e || window.event; 4 var code = theEvent.keyCode || theEvent.which || theEvent.charCode; 5 if (code == 13) { 6 //回车执行查询 7 $("#queryButton").click(); 8 } 9 });