如何解决菜单悬停问题

发布于 2025-01-02 18:00:17 字数 2494 浏览 0 评论 0原文

我在一个网站上工作,但其菜单遇到了问题。当我将鼠标悬停在菜单上时,其子菜单不会出现。所以请帮我解决这个问题。

在此处输入图像描述

全尺寸图片

http://www.mulberrydesignerkitchens.com/

我一直使用一段代码来实现 jQuery 菜单,

var $jnav = jQuery.noConflict();
$jnav(document).ready(function () {
    $jnav('#menu-mainnav li').hover(

    function () {
        $jnav(this).css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-current-bg.png') no-repeat", 'cursor', "pointer");
        if ($jnav(this).is('#menu-mainnav li:last-child')) {
            $jnav('#menu-mainnav li:last-child').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-last-bg.png') no-repeat");
        } else if ($jnav(this).is('.sub-menu li:last-child')) {
            $jnav('.sub-menu li:last-child').css('background', "none scroll #8e4d69");
        }
    }, function () {
        if (!$jnav(this).hasClass('current-menu-item')) {
            $jnav(this).css('background', "none");
        }
        if (!$jnav('#menu-mainnav li:first').hasClass('current-menu-item')) {
            $jnav('#menu-mainnav li:first').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-first-bg.png') no-repeat");
        }
    })
    $jnav('#menu-mainnav li ul li').hover(

    function () {
        $jnav(this).css('background-color', "#8e4d69", 'cursor', "pointer");
    }, function () {
        if (!$jnav(this).hasClass('current-menu-item')) {
            $jnav(this).css('background', "#833b5d");
        }
    })
    if (!$jnav('.superfish li:first').hasClass('current-menu-item')) $jnav('.superfish li:first').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-first-bg.png') no-repeat");
    $jnav('.superfish li.current-menu-item:last-child').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-last-bg.png') no-repeat");
    if (!$jnav('.sub-menu li:first').hasClass('current-menu-item')) $jnav('.sub-menu li:first').css('background', "#833b5d");
    $jnav('.sub-menu li.current-menu-item:last-child').css('background', "#833b5d");

    $jnav('ul.superfish').superfish();
});

我必须单击导航才能看到它的子菜单。请帮我解决这个问题。

谢谢。

i work on a website and having trouble with its menu. when i hover over the menu, its sub-menu doesnot appear. so please kindly help me to sort out this issue.

enter image description here

Full size image

http://www.mulberrydesignerkitchens.com/

i m using a piece of code to implement jQuery menu

var $jnav = jQuery.noConflict();
$jnav(document).ready(function () {
    $jnav('#menu-mainnav li').hover(

    function () {
        $jnav(this).css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-current-bg.png') no-repeat", 'cursor', "pointer");
        if ($jnav(this).is('#menu-mainnav li:last-child')) {
            $jnav('#menu-mainnav li:last-child').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-last-bg.png') no-repeat");
        } else if ($jnav(this).is('.sub-menu li:last-child')) {
            $jnav('.sub-menu li:last-child').css('background', "none scroll #8e4d69");
        }
    }, function () {
        if (!$jnav(this).hasClass('current-menu-item')) {
            $jnav(this).css('background', "none");
        }
        if (!$jnav('#menu-mainnav li:first').hasClass('current-menu-item')) {
            $jnav('#menu-mainnav li:first').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-first-bg.png') no-repeat");
        }
    })
    $jnav('#menu-mainnav li ul li').hover(

    function () {
        $jnav(this).css('background-color', "#8e4d69", 'cursor', "pointer");
    }, function () {
        if (!$jnav(this).hasClass('current-menu-item')) {
            $jnav(this).css('background', "#833b5d");
        }
    })
    if (!$jnav('.superfish li:first').hasClass('current-menu-item')) $jnav('.superfish li:first').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-first-bg.png') no-repeat");
    $jnav('.superfish li.current-menu-item:last-child').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-last-bg.png') no-repeat");
    if (!$jnav('.sub-menu li:first').hasClass('current-menu-item')) $jnav('.sub-menu li:first').css('background', "#833b5d");
    $jnav('.sub-menu li.current-menu-item:last-child').css('background', "#833b5d");

    $jnav('ul.superfish').superfish();
});

all the time i have to click over the navigation to see it sub-menu. plz plz plz help me to solve this issue.

thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲影 2025-01-09 18:00:17

您有两个菜单脚本相互争夺菜单的悬停事件(Suckerfish 和 jNav),删除其中之一,您的菜单应该得到修复。

var $jnav = jQuery.noConflict();
$jnav(document).ready(function () {
    $jnav('#menu-mainnav li').hover(

    function () {
        $jnav(this).css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-current-bg.png') no-repeat", 'cursor', "pointer");
        if ($jnav(this).is('#menu-mainnav li:last-child')) {
            $jnav('#menu-mainnav li:last-child').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-last-bg.png') no-repeat");
        } else if ($jnav(this).is('.sub-menu li:last-child')) {
            $jnav('.sub-menu li:last-child').css('background', "none scroll #8e4d69");
        }
    }, function () {
        if (!$jnav(this).hasClass('current-menu-item')) {
            $jnav(this).css('background', "none");
        }
        if (!$jnav('#menu-mainnav li:first').hasClass('current-menu-item')) {
            $jnav('#menu-mainnav li:first').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-first-bg.png') no-repeat");
        }
    })
    $jnav('#menu-mainnav li ul li').hover(

    function () {
        $jnav(this).css('background-color', "#8e4d69", 'cursor', "pointer");
    }, function () {
        if (!$jnav(this).hasClass('current-menu-item')) {
            $jnav(this).css('background', "#833b5d");
        }
    })
    if (!$jnav('.superfish li:first').hasClass('current-menu-item')) $jnav('.superfish li:first').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-first-bg.png') no-repeat");
    $jnav('.superfish li.current-menu-item:last-child').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-last-bg.png') no-repeat");
    if (!$jnav('.sub-menu li:first').hasClass('current-menu-item')) $jnav('.sub-menu li:first').css('background', "#833b5d");
    $jnav('.sub-menu li.current-menu-item:last-child').css('background', "#833b5d");
    jQuery('.lightbox').lightBox({
        imageLoading: 'http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/lightbox-ico-loading.gif',
        imageBtnClose: 'http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/lightbox-btn-close.gif',
        imageBtnPrev: 'http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/lightbox-btn-prev.gif',
        imageBtnNext: 'http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/lightbox-btn-next.gif'
    });
    $jnav('#logo').hover(function () {
        $jnav(this).css('opacity', '0.8');
    }, function () {
        $jnav(this).css('opacity', '1');
    });
    $jnav('#homepage-images h4').css('display', 'none');
    $jnav('ul.superfish').superfish({
        hoverClass: 'nav#primary-menu a'
    });
});

要让吸盘鱼发挥作用,您需要做的是:

<script> 

    $(document).ready(function() { 
        $('ul.sf-menu').superfish(); 
    }); 

</script>

You have two menu scripts fighting each other for the hover event of your menu (Suckerfish and jNav), remove one of them and your menu should be fixed.

var $jnav = jQuery.noConflict();
$jnav(document).ready(function () {
    $jnav('#menu-mainnav li').hover(

    function () {
        $jnav(this).css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-current-bg.png') no-repeat", 'cursor', "pointer");
        if ($jnav(this).is('#menu-mainnav li:last-child')) {
            $jnav('#menu-mainnav li:last-child').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-last-bg.png') no-repeat");
        } else if ($jnav(this).is('.sub-menu li:last-child')) {
            $jnav('.sub-menu li:last-child').css('background', "none scroll #8e4d69");
        }
    }, function () {
        if (!$jnav(this).hasClass('current-menu-item')) {
            $jnav(this).css('background', "none");
        }
        if (!$jnav('#menu-mainnav li:first').hasClass('current-menu-item')) {
            $jnav('#menu-mainnav li:first').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-first-bg.png') no-repeat");
        }
    })
    $jnav('#menu-mainnav li ul li').hover(

    function () {
        $jnav(this).css('background-color', "#8e4d69", 'cursor', "pointer");
    }, function () {
        if (!$jnav(this).hasClass('current-menu-item')) {
            $jnav(this).css('background', "#833b5d");
        }
    })
    if (!$jnav('.superfish li:first').hasClass('current-menu-item')) $jnav('.superfish li:first').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-first-bg.png') no-repeat");
    $jnav('.superfish li.current-menu-item:last-child').css('background', "url('http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/nav-last-bg.png') no-repeat");
    if (!$jnav('.sub-menu li:first').hasClass('current-menu-item')) $jnav('.sub-menu li:first').css('background', "#833b5d");
    $jnav('.sub-menu li.current-menu-item:last-child').css('background', "#833b5d");
    jQuery('.lightbox').lightBox({
        imageLoading: 'http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/lightbox-ico-loading.gif',
        imageBtnClose: 'http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/lightbox-btn-close.gif',
        imageBtnPrev: 'http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/lightbox-btn-prev.gif',
        imageBtnNext: 'http://www.mulberrydesignerkitchens.com/wp-content/themes/MBK/images/lightbox-btn-next.gif'
    });
    $jnav('#logo').hover(function () {
        $jnav(this).css('opacity', '0.8');
    }, function () {
        $jnav(this).css('opacity', '1');
    });
    $jnav('#homepage-images h4').css('display', 'none');
    $jnav('ul.superfish').superfish({
        hoverClass: 'nav#primary-menu a'
    });
});

For suckerfish to work all you need is:

<script> 

    $(document).ready(function() { 
        $('ul.sf-menu').superfish(); 
    }); 

</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文