JS 监听输入框按键
//回车事件绑定
$('#search_input').bind('keyup', function(event) {
if (event.keyCode == '13') {
//处理按回车键后的逻辑
}
});
JS 监听某个 DIV 区域
$("#div").bind("keydown", function(e){
// 兼容FF和IE和Opera
var theEvent = e || window.event;
var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
if (code == '13') {
//处理按回车键后的逻辑
}
});
JS监听body区域
document.onkeydown = function (event) {
var e = event || window.event;
if (e && e.keyCode == 13) {
//处理按回车键后的逻辑
}
}
ConstXiong 备案号:苏ICP备16009629号-3