0

我在 IE9 中遇到了弹出 div 的问题,代码如下:

<li id="info001" class="listInfo" onmouseover="ShowPreview(this);" onmouseout="HidePreview();">

并且我的 HidePreview 检查以确保鼠标不在 listItem 或预览本身上,如下所示:

function HidePreview() {
    if (!($('#thePreview').is(':hover') || $('#info001').is(':hover'))) {
        $('#thePreview').hide();
    }
}

这在 Chrome 和 Firefox 中运行良好,但在 IE9 中,当我移动 listItem 和预览时,预览开始闪烁,然后当我单独移动预览时,它会被隐藏。

有没有办法避免这种情况?

编辑:为清楚起见,thePreview div 与 info001 li 重叠,足以轻松地在它们之间移动鼠标。

编辑:http: //jsfiddle.net/ControlFreak/QQsGS/

4

1 回答 1

0

尝试做这样的事情:

var $thePreview = $("#thePreview");

$(".listInfo").hover(
    function () {
        $thePreview.show();
    },
    function () {
        $thePreview.hide();
    }
);

jsFiddle 上的工作示例

您仍然可以使用该代码,只需将伪事件从 hover 更改为 mouseenter mouseleave(如果您运行的是 1.9+)。有关更多信息,请参见:jquery.com/upgrade-guide/1.9/#hover-pseudo-event

于 2013-02-08T19:34:40.390 回答