jquery中的event

在最近写js的时候,发现了一个代码的兼容性有些问题(ie能跑,火狐不行),心中还在疑惑怎么会这样,不是jquery的跨浏览器兼容做得很好的么,后来查阅官方文档之后才知道是我的使用有问题,记录一下,供自己和各位参考。

1.问题原因

         问题出现的原因是我在代码中使用了event的srcElement这个属性,这个属性在ie中有,但是在FF中就没有(目前没验证其他的浏览器),所以代码在ie中能够正常,ff中却出现了问题。

2.jquery中event的标准属性

         在查阅了jquery的官方文档之后官方文档,知道jquery只将以下六个属性作为能够跨浏览器的属性,官方的描述日下:

2.1target

         The DOM element that initiated the event.

         The target property can be the element that registered for the event or a descendant of it. It is often useful to compare event.target to this in order to determine if the event is being handled due to event bubbling. This property is very useful in event delegation, when events bubble.

2.2relatedTarget

          The other DOM element involved in the event, if any.

         

           For mouseout, indicates the element being entered; for mouseover, indicates the element being exited.

 

2.3pageX

        

           The mouse position relative to the left edge of the document.

2.4pageY

         

           The mouse position relative to the top edge of the document.

2.5which

           For key or mouse events, this property indicates the specific key or button that was pressed.

 

2.6metaKey

           Returns a boolean value (true or false) that indicates whether or not the META key was pressed at the time the event fired. This key might map to an alternative key name on some platforms.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值