首页 > 编程 > JavaScript > 正文

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

2019-11-19 12:44:45
字体:
来源:转载
供稿:网友

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

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事件绑定的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林网。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表