English 中文(简体)
我如何清理我的子菜单?
原标题:How do I clean up my sub menu code?

我正试图冲倒一个小的菜单,然后把小菜 visible放在一边,直到把另一个选择隔开。

我也想掩盖子菜单,如果它不 over在一只#或 n子上。 帮助请。

$(document).ready(function () {
    $( a#about ).hover(function(){
        $( nav#about ).slideDown();
    });

    $( nav#about ).hover(function(){
        $( nav#about ).slideDown();
    });

    $( a#home ).hover(function(){
        $( nav#about ).slideUp();
    });

    $( a#products ).hover(function(){
        $( nav#about ).slideUp();
    });

    $( a#contact ).hover(function(){
        $( nav#about ).slideUp();
    });
});

========================================= edited to include the html

<nav id="main" class="left">
    <a id="home" class="left active">Home</a>
    <a id="about" class="left" href="#">About</a>
    <a id="products" class="left" href="#">Products</a>
    <a id="contact" class="left" href="#">Contact</a>
</nav>

<nav id="about" class="left">
    <a href="#"></a><br />
    <a href="#"></a><br />
    <a href="#"></a><br />
    <a href="#"></a><br />
    <a href="#"></a><br />
</nav>
最佳回答

I am trying to slide down a sub menu when hovering over a#about and keep the sub menu visible until hovering over another option

假设所有导航<代码>divs有nav的类别属性,导航链接按<代码>div或nav加以包装。 与此类似:

<div id="navigation">
    <a id="about" ...>About</a>
    <a id="home" ...>Home</a>
    <a id="products" ...>Products</a>
    <a id="contact" ...>Contact</a>
    <div class="nav" id="div-about" ...>...</div>
</div>

你可以这样做:

var menuTimeout;
$( #navigation a, #navigation .nav ).hover(function() {
    hovered_div = $( #navigation #  +  div-  + $(this).attr( id ).replace( div- ,  ));
    $( #navigation .nav ).not(hovered_div).hide();
    (hovered_div.css( display ) ==  none ) && hovered_div.slideDown();
    clearTimeout(menuTimeout);
}, function() {
       menuTimeout = setTimeout(function() { $( #navigation .nav ).slideUp(); }, 1000);
   });
});

基本约束为<条码>hover >>> 条码和<条码>部分。 类别和隐藏所有<代码>nav divs,但目前的四分(被 h)和滑坡除外。 如果四舍五入,则将四舍五入至四舍五入至四舍五入,则在四舍五入后采用<>代码>准时射线(<>>>>

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签