[英]Jquery On not working in IE9
The following code works fine in all my CSS3 browsers except for IE9. 下面的代码在我所有的CSS3浏览器(IE9除外)中都可以正常工作。 Does anyone have an idea why? 有谁知道为什么? I have several divs of class dismdiv set up in big div with ID fpdiv. 我在ID为fpdiv的大div中设置了类dismdiv的几个div。 I should get alert boxes on enter and exit of each of my dimsdiv areas. 我应该在每个dimsdiv区域的进入和退出处得到警告框。 But not in IE9 for some reason. 但由于某种原因,它不在IE9中。
Thanks, in advance! 提前致谢!
this.setDimsRoll = function() {
$("#fpdiv").on({
mouseenter : function() {
alert("on")
},
mouseleave : function() {
alert("off");
}
}, ".dimsdiv");
}
Some clarification. 一些澄清。 This is a method in a javascript 'class' thus, the 'this'. 这是javascript“类”中的方法,因此为“ this”。 You can ignore that part. 您可以忽略该部分。 This gets called after the dimsdivs are created dynamically. 在动态创建dimsdivs之后调用此函数。 That's why I opted for this method as a reslt of my other post: 这就是为什么我选择此方法作为我其他帖子的转载:
Jquery - How to I add an event after dynamic create jQuery-如何在动态创建后添加事件
Normally, I would just use hover or something else, but this was required to handle the dynamic objects. 通常,我只使用悬停或其他方法,但这是处理动态对象所必需的。
I suspect that you should be binding to document object's event seeing as the elements are dynamically created. 我怀疑您应该绑定到文档对象的事件,因为元素是动态创建的。 Something along the lines of: 类似于以下内容:
this.setDimsRoll = function() {
$(document).on({
mouseenter: function () {
alert("on")
},
mouseleave: function () {
alert("off")
}
}, '.dimsdiv');
}
Also on a side note your contexts seem slighly mixed up. 另外,请注意,您的上下文似乎有点混乱。 Which element are you actually trying to bind the mouse events to .dimsdiv
or #fpdiv
? 您实际上是在尝试将鼠标事件绑定到.dimsdiv
或#fpdiv
哪个元素?
The solution was to fill the div with a clear pixel. 解决的办法是用清晰的像素填充div。 Turns out that empty divs don't detect on IE. 原来,空div不会在IE上检测到。 Thanks Microsoft! 谢谢微软!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.