在我的代码中,我有一个 id 为“SIAinfoBox”的 div,根据鼠标当前所在的 div 来加载不同的详细信息。我将以下两个监听器附加到每个相关的 div:
$(annoDiv).mouseover(function(event){
event.stopPropagation;
$('#SIAinfoBox').empty();
$('#SIAinfoBox').append(details);
$('#SIAinfoBox').css('visibility','visible');
});
$(annoDiv).mouseleave(function(event){
event.stopPropagation;
$('#SIAinfoBox').empty();
$('#SIAinfoBox').css('visibility','hidden');
});
这些 div 没有设置背景颜色,但有 1 像素的纯黑色边框。在 Firefox 中,一切都运行良好。但在 Internet Explorer 中,仅当鼠标位于 div 边框上方时,SIAinfoBox 才会被填充。将其移动到 div 内似乎会触发 mouseleave 事件,并且内容将被删除并隐藏 div。如果我设置背景颜色,它会像预期的那样工作,但是如果没有背景颜色(或透明),它就不起作用。我也尝试过使用 mouseenter 而不是 mouseover,但结果相同。 为什么 InternetExplorer 会有这样的行为,或者我可以采取什么措施来实现我目前在 FF for IE 中获得的结果?
最佳答案
I've had similar IE related issues such as this - you could make a transparent png and set the background to "url(images/transparent.png) repeat scroll 0 0 transparent" – SmokeyPHP
首先没有找到他的评论,所以我将其移至此处作为答案。可以通过以下链接找到透明图像:
答案: style="background:url(images/transparent.png) 重复滚动 0 0 透明"
关于jquery - Mouseenter 仅在 IE9 中的透明 div 边框上触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7799459/