首页 > 其他 > 详细

input框触发回车事件

时间:2019-03-07 00:44:18      阅读:475      评论:0      收藏:0      [点我收藏+]

 

window.event只能在IE下运行,不能在firefox下运行,这是因为firefox的event只能在事件发生的现场使用。   
在firefox里直接调用event对象会报undefined。
兼容解决方式:

<input type="text" onkeydown="keyup_submit(event);">

<script>
function keyup_submit(e){ 
 var evt = window.event || e; 
  if (evt.keyCode == 13){
    //回车事件
  console.log(e.target.attributes);
  }
}
</script>

 

如果要获取元素的属性等:

 

console.log(e.target.attributes);

 

转 : https://www.cnblogs.com/houweijian/p/5808978.html

 

input框触发回车事件

原文:https://www.cnblogs.com/fps2tao/p/10486956.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!