javascript - 圆形菜单中的错误

标签 javascript jquery html css

菜单本身:http://codepen.io/anon/pen/zxXvoG

<!-- language: lang-js -->
$(document).ready(function() {
    $('a').hover(function() {
        $("ul li").eq($(this).index()).trigger("mouseover");
    }, function() {
        $("ul li").eq($(this).index()).trigger("mouseout");
    });
    $('li').hover(function() {
        $('a').eq($(this).index()).css('background-color', '#333333');
        $(this).css('background-color', '#333333');
    }, function() {
        $('a').eq($(this).index()).css('background-color', '#666666');
        $(this).css('background-color', '#666666');
    });
});
$( "a" )
  .on( "mouseenter", function() {
    $( this ).css({
      "color": "#00CAF2"
    });
  })
  .on( "mouseleave", function() {
    var styles = {
      "color":""
    };
    $( this ).css( styles );
  });

问题:当您将鼠标悬停在一个链接上时, block 通常会被选中,但是当您将光标从菜单项标题移动到它的 block 时,为什么 block “ssssssss8”(“ul”列表中的第一个 block )也会被选中。

最佳答案

删除了 $('a').hover 函数,'ssssssss8' 不再阻塞。请参阅下面的注释代码,

$(document).ready(function() {
        //$('a').hover(function() {
            //$("ul li").eq($(this).index()).trigger("mouseover");
        //}, function() {
            //$("ul li").eq($(this).index()).trigger("mouseout");
        //});

        $('li').hover(function() {
            $('a').eq($(this).index()).css('background-color', '#333333');
            $(this).css('background-color', '#333333');
        }, function() {
            $('a').eq($(this).index()).css('background-color', '#666666');
            $(this).css('background-color', '#666666');
        });
    });

关于javascript - 圆形菜单中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29377583/

相关文章:

javascript - 平均 : Getting Error 400 (Bad Request) on POST

javascript - 在ajax成功后动态更新/刷新html而无需重新加载页面

javascript - 如何从 $ ('p' 的集合中删除所有类?

javascript - 如何打开和关闭 Bulma 模型 Jquery 切换属性

只有隐藏输入的 HTML 表单在 FireFox 中创建额外的空白

javascript - 如何从子状态更改父状态 - Mobx 状态树?

javascript - .fadeIn() 和 .fadeOut() 在 for 循环中不起作用

javascript - 想了解 SounManager Player ID

即使链接不是当前链接,jQuery CSS 样式也保持不变

javascript - 提交按钮重新加载页面