2013-06-26 172 views
0

我想弄清楚如何隱藏其他子菜單項並單擊菜單。現在,當兩個菜單都被點擊時,它們都顯示出來,我不想要。單擊菜單時我想隱藏其他菜單項

<script type="text/javascript" src="jquery/js/jquery-1.9.1.js"></script> 
<script src="jquery/js/jquery-ui-1.10.3.custom.js"></script> 
<script> 
jQuery(function ($) { 
    $(".accordion").accordion({ 
     active: false, 
     autoHeight: false, 
     collapsible: true, 
     alwaysOpen: false 
    }); 

    function collapseAll() { 
     $("#accordion") 
      .filter(":has(.ui-state-active)") 
      .accordion("activate", -1); 
     $(".ui-accordion-header").blur(); 

    } 
}); 

<div class="navigation"> 
    <ul class="accordion"> 
     <li> 
      <asp:HyperLink ID="about" runat="server" href="#" text="testing" /> 
      <div class="sub accordion"> 
       <ul> 
        <li><asp:HyperLink ID="aboutTraci" runat="server" NavigateUrl="traci.aspx" Text="Traci" /></li> 
        <li><asp:HyperLink ID="aboutTheBegan" runat="server" NavigateUrl="#" Text="How It All Began" /></li> 
        <li><asp:HyperLink ID="aboutDesigners" runat="server" NavigateUrl="#" Text="Designers" /></li> 
        <li><asp:HyperLink ID="aboutPlaygroup" runat="server" NavigateUrl="#" Text="Playgroup" /></li> 
        <li><asp:HyperLink ID="aboutPlayground" runat="server" NavigateUrl="#" Text="Playground" /></li> 
        <li><asp:HyperLink ID="aboutTestimonials" runat="server" NavigateUrl="testimonials.aspx" Text="Testimonials" /></li> 
       </ul> 
      </div> 
     </li> 
    </ul> 
    <ul class="accordion"> 
     <li> 
      <asp:HyperLink ID="HyperLink1" runat="server" href="#" Text="testing" /> 
      <div class="sub accordion"> 
       <ul> 
        <li><asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="traci.aspx" Text="Traci" /></li> 
        <li><asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl="#" Text="How It All Began" /></li> 
        <li><asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl="#" Text="Designers" /></li> 
        <li><asp:HyperLink ID="HyperLink5" runat="server" NavigateUrl="#" Text="Playgroup" /></li> 
        <li><asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl="#" Text="Playground" /></li> 
        <li><asp:HyperLink ID="HyperLink7" runat="server" NavigateUrl="testimonials.aspx" Text="Testimonials" /></li> 
       </ul> 
      </div> 
     </li> 
    </ul> 
</div> 

我想隱藏其他菜單項被點擊時一個。

謝謝

回答

0

要隱藏其他菜單項被點擊你要組織你的HTML的方式,手風琴API可以加入標題,像這樣它的意義,當一個:example fiddle

<ul class="accordion"> 
     <li> 
      <h3>Section 1</h3> 
      <ul class="accordion"> 
       <li> 
        <h4> Link 1</h4><p>content</p> 
       </li> 
       <li> 
        <h4> Link 2</h4><p>content</p> 
       </li> 
       <li> 
        <h4> Link 3</h4><p>content</p> 
       </li> 
      </ul> 
     </li> 
     <li> 
      <h3>Section 2</h3> 
      <ul class="accordion"> 
       <li> 
        <h4> Link 1</h4><p>content</p> 
       </li> 
       <li> 
        <h4> Link 2</h4><p>content</p> 
       </li> 
       <li> 
        <h4> Link 3</h4><p>content</p> 
       </li> 
      </ul> 
     </li> 
    </ul>