Jquery等同于onmouseover(IE)/ mouseover(FF)来编写适用于两者的跨浏览器代码 [英] Jquery's equivalent for onmouseover(IE)/mouseover(FF) to write cross browser code which works for both

查看:88
本文介绍了Jquery等同于onmouseover(IE)/ mouseover(FF)来编写适用于两者的跨浏览器代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var node = this.doc.createElement("span");
 node.setAttribute("id","123");
 node.setAttribute("title", "sample");
  node.addEventListener('mouseover', ev_onMouseOver, false); ----FF
node.attachEvent("onmouseover", ev_onMouseOver); ---- For IE < 9



我在Mouseover事件中使用了两种方法来添加eventhandler,一种用于IE,另一种用于FF

我的问题是:Jquery有一些方法或方法,所以我不必在这里使用两种不同的方式。

我浏览了博客,它讲述了Jquery'的''bind''和''on''方法以及特定的鼠标悬停方法,但无法决定使用哪一个。

我也是JS的新手,所以我无法弄清楚在Jquery中编写它的确切语法。


I have used two ways to add eventhandler on Mouseover event, one for IE and other for FF
My question is : Does Jquery has some method or way so that i dont have to use two different way here.
I went through blogs which does tell about Jquery''s ''bind'' and ''on'' method and also specific mouseover method but couldnt make a decision yet which one to use.
Also i am pretty new to JS, so i couldn''t figure out exact syntax to write it in Jquery.

推荐答案

看看在此,
Look at this,


.bind [ ^ ]还有
.bind[^] there is also


.on [ ^ ]这是首选方法。
.on[^] which is the preferred method.


这篇关于Jquery等同于onmouseover(IE)/ mouseover(FF)来编写适用于两者的跨浏览器代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆