IE选择悬停问题 [英] IE select issue with hover

查看:23
本文介绍了IE选择悬停问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和一个朋友正在尝试解决 IE (7/8).我们在这里建立了一个规范的例子:

A friend and myself are trying to workaround IE (7/8). We have built a canonical example here:

http://www.mathgladiator.com/分享/ie-select-bug-hover-css-menus.htm

使用 CSS 菜单,我们希望在其中进行选择.但是,在 IE 中,当您与选择框交互时,菜单就会消失.我们认为这与选择如何影响事件的错误有关.

Using a CSS menu, we would like to have selects in them. However, in IE, the menu goes away when you interact with the select box. We believe this has to do with a bug in how selects affect events.

有解决方法吗?至少使用纯 CSS 或 DOM hack?

Is there a workaround? At least with pure CSS or DOM hacks?

推荐答案

我不认为有一个纯 CSS 的方式来解决这个问题.这是由于 IE 在选择元素上处理事件的方式存在一个非常常见的错误.

I do not think there is a pure CSS way around this. This is due to a very common bug to the way IE handles events on select elements.

您可以使用 Javascript 解决它:

You can however work around it with Javascript:

<script type="text/javascript">
    $(document).ready(function () {
        $('.nav_element a').mouseover(function() {
            $('.submenu').hide();
            $(this).parent().find('.submenu').show();
        });

        $('.submenu').mouseover(function() {
            $(this).show();
        });

        $('.submenu').mouseout(function (e) {
            // Do not close if going over to a select element
            if (e.target.tagName.toLowerCase() == 'select') return;
            $(this).hide();
        });

    });    
</script>

上面的代码使用了jQuery.

The code above uses jQuery.

这篇关于IE选择悬停问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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