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