English 中文(简体)
j Query: P reserves hover state when come out elements?
原标题:jQuery: Preserve hover state when coming off element?
  • 时间:2012-01-15 10:20:48
  •  标签:
  • jquery

1. 导言 我有2个男子,即“Main”和“Sub”——当你在主要环节上把一个特定环节 h倒时,我强调子菜,给它增加一个类别......great 当我把“主要利子”的颜色 off回正常......时,我需要保留这一颜色,如果我把这个颜色推到底......例如,他们都强调......。

  1. ...then.... once I actually hover onto the sub nav....then the highlighting would cease...and only the sub menu item link i roll onto goes the highlighted colour (This can just be the normal "a:hover" state.

So I guess in a nutshell..

主要菜单项目......次菜单项目已着重指出......从主角开始......小菜单仍然强调......(但只有从主子到子才能强调这一点),否则会放松强调)...... (标准a:子菜单的over)

Here s my code thus far, which activates the global highlighting:

<ul id="primarynav">
    <li><a href="">home</a></li>
    <li class="portfolio"><a href="">protfolio</a></li>
    <li><a href="">contact</a></li>
</ul>

<!-- Secondary nav -->

<ul id="secondarynav">
    <li><a href="">Websites</a></li>
    <li><a href="">Graphics</a></li>
    <li><a href="">Drawing</a></li>
</ul>


$(document).ready(function(){
    var $primarynav = $( #primarynav .portfolio ),
        $secondarynav = $( #secondarynav );

    $primarynav.hover(function(){
        $secondarynav.addClass( highlight );
    }, function(){
        $secondarynav.removeClass( highlight );
    });
});
问题回答

你们指的是:

<ul id="primarynav">
    <li><a href="">home</a></li>
    <li class="portfolio"><a href="">protfolio</a></li>
    <li><a href="">contact</a></li>
</ul>

<!-- Secondary nav -->

<ul id="secondarynav">
    <li><a href="">Websites</a></li>
    <li><a href="">Graphics</a></li>
    <li><a href="">Drawing</a></li>
</ul>


$(document).ready(function(){
    var $primarynav = $( #primarynav .portfolio ),
        $secondarynav = $( #secondarynav );

    $primarynav.hover(function(){
        $secondarynav.addClass( highlight );
    });

    $secondarynav.hover(function(){
        $secondarynav.removeClass( highlight);
    });
});
  • It highlights the subnav when hovering the main nav
  • It doesn t take the highlight away when leaving the main nav
  • The highlight goes away when hovering the submenu




相关问题
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: &...

热门标签