JavaScript

超轻量级php框架startmvc

js实现同一个页面,多个enter事件绑定的示例

更新时间:2020-07-31 23:00:01 作者:startmvc
困得不行了,脑袋转不动了,大家直接拿代码用吧。。。document.onkeydown=function(e){varev=(typeofe

困得不行了 ,脑袋转不动了,大家直接拿代码用吧。。。


document.onkeydown = function(e) {
 var ev = (typeof event!= 'undefined') ? window.event : e;
 if(ev.keyCode == 13 && document.activeElement.id == "") {//activeElement活动事件,该事件只可以使用于输入域中
 console.log("内容111:" + document.activeElement.value);
 }else if(ev.keyCode==13&& document.activeElement.id==''){
 console.log("内容222:" + document.activeElement.value);
 }
};

以上这篇js实现同一个页面,多个enter事件绑定的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

js enter 事件绑定