菜单onhover隐藏问题jquery

时间:2014-02-22 08:05:03

标签: javascript jquery html

$("#men1").hoverIntent({
    over: makeTall
});
$("#men2").hoverIntent({
    over: makeTall
});

我的jquery是

function makeTall()
{
    //$("#mainmenu div").mouseover(function() {
    var val = $(this).data("id");
    $(".sub-menu-" + val).slideToggle(500);
    $(".sub-menu-" + val).siblings().slideUp(500);
    var className = $(this).attr("class").split(" ");
    var iid = $(this).attr("id").split(" ");
    $("." + className[0]).addClass("active");
    //  alert(iid);
    $("." + className[0]).siblings().removeClass("active");

    // hide id submenu is open 
    function hideParent() {
        if ($(".sub-menu-" + val).is(':visible')) {
            $("." + className).removeClass("active");
            $(".sub-menu-" + val).slideUp(500);
        }
        else{

        }
    }
    setInterval(function () {
        hideParent();
    }, 10000);
}

html

<div id="mainmenu" class="navigation">
<div class="main-menu-1" data-id="1" id="men1">
</div>
<div class="main-menu-2" data-id="2" id="men2" >
</div>
<div class="main-menu-3" data-id="3" id="men3" >
</div>
<div class="main-menu-4" data-id="4" id="men4" >
</div>
<div class="main-menu-5" data-id="5" id="men5" >
</div>
<div class="main-menu-6" data-id="6" id="men6" >
</div>
</div>

<div class="sub-menu-1 sub-menu" data-id="1" style="display: none;">
this is sub menu1
</div>
<div class="sub-menu-2 sub-menu" data-id="2" style="display: none;">
this is sub menu2
</div>

hideParent()函数隐藏了子菜单,但我需要隐藏onmouseout它不工作..

0 个答案:

没有答案