有JS控制的方法吗,搜一搜,找不到适合的进入另一个页面后,当前菜单高亮
在二 三级菜单下,高亮的还是第一级菜单JS JQ的方法都行

解决方案 »

  1.   

    1.取得当前网页地址URL
    2.判断该URL属于哪个菜单(找到其第一级菜单)
    3.高亮显示该菜单
      

  2.   

    代码来源 http://static.jquery.com/files/rocker/scripts/custom.jsvar loc = window.location.href;
    //strip the existing current state
    $('#jq-secondaryNavigation .jq-current').removeClass('jq-current');//add class to current section...
    //Download
    if(loc.indexOf('http://docs.jquery.com/Downloading_jQuery') > -1){
           $('#jq-secondaryNavigation .jq-download').addClass('jq-current');
    }
    //Tutorials
    else if(loc.indexOf('http://docs.jquery.com/Tutorials') > -1){
           $('#jq-secondaryNavigation .jq-tutorials').addClass('jq-current');
    }
    //Discussion
    else if(loc.indexOf('http://docs.jquery.com/Discussion') > -1){
           $('#jq-secondaryNavigation .jq-discussion').addClass('jq-current');
    }
    //UI within docs
    else if(loc.indexOf('http://docs.jquery.com/UI') > -1){
           $('#jq-primaryNavigation .jq-current').removeClass('jq-current');
           $('#jq-primaryNavigation .jq-ui').addClass('jq-current');
           $('#jq-secondaryNavigation .jq-documentation').addClass('jq-current');
    }
    //About
    else if(loc.indexOf('http://docs.jquery.com/About') > -1){
           $('#jq-primaryNavigation .jq-current').removeClass('jq-current');
           $('#jq-primaryNavigation .jq-about').addClass('jq-current');
    }
    //Donate
    else if(loc.indexOf('http://docs.jquery.com/Donate') > -1){
           $('#jq-primaryNavigation .jq-current').removeClass('jq-current');
           $('#jq-primaryNavigation .jq-donate').addClass('jq-current');
    }
    //Docs, in general
    else if(loc.indexOf('http://docs.jquery.com/') > -1){
           $('#jq-secondaryNavigation .jq-documentation').addClass('jq-current');
    }
    // Dev
    else if(loc.indexOf('http://dev.jquery.com/') > -1){
           $('#jq-secondaryNavigation .jq-bugTracker').addClass('jq-current');
    }
    //plugins popular
    else if(loc.indexOf('http://plugins.jquery.com/most_popular') > -1){
     $('#jq-secondaryNavigation .jq-popularPlugins').addClass('jq-current');
    }
    //plugins latest
    else if(loc.indexOf('http://plugins.jquery.com/latest_releases') > -1){
     $('#jq-secondaryNavigation .jq-latestReleases').addClass('jq-current');
    }
    //plugins browse
    else if(loc.indexOf('http://plugins.jquery.com/project/Plugins') > -1){
     $('#jq-secondaryNavigation .jq-browseCategories').addClass('jq-current');
    }
    //plugins lates
    else if(loc.indexOf('http://plugins.jquery.com/project/Plugins/name') > -1){
     $('#jq-secondaryNavigation .jq-allPlugins').addClass('jq-current');
    }用url判断当前的菜单,jq-current 是当前菜单的class