jquery - 悬停状态很古怪

标签 jquery css jquery-selectors

我一直在研究一个下拉菜单,父项和子项都有不同的颜色,当处于悬停状态时颜色会发生变化:

http://jsfiddle.net/cELJ6/1/

不过我对此有个小怪癖。

Home 链接没有悬停,ProductsSection2 也没有悬停。

问题是:

1) 当我将鼠标悬停在 Product 上时,链接的颜色需要为白色。 (BG 颜色很好,工作正常)

2) 当我将鼠标悬停在子元素上时,例如 Product1Products 链接颜色需要为白色

ProductsSection2 之间徘徊似乎很古怪。颜色有时是白色,有时是灰色 (#777)

有解决办法吗?

谢谢

最佳答案

$('ul > li.leaf').each(function(){
    $(this).mouseenter(function(e){
        $(this).find('a').css('color','white');
    });
    $(this).mouseleave(function(e){
        $(this).find('a').css('color','#777777');
    });

   });

 $('.expanded > ul.leaf').each(function(){
    $(this).mouseenter(function(e){
        $(this).find('a').css('color','white');
    });
    $(this).mouseleave(function(e){
        $(this).find('a').css('color','#777777');
    });

   });

关于jquery - 悬停状态很古怪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10812255/

相关文章:

javascript - 什么时候用javascript封装?

jquery - 如何使用 jquery 查找 id 中的数字并选中复选框

javascript - trim 函数结果

javascript - "overflow-wrap:break-word"的浏览器兼容性

javascript - 获取下拉框中所选项目的id属性

javascript - 简单的 jquery .post 不返回数据

html - AngularJS 和文本 Angular : Change CSS style for input placeholder

html - 在 IE8 中选择填充

jquery - 您可以在 jQuery 选择器上执行 'AND' 来定位多个按钮吗?

javascript - 用单击的按钮填充文本区域