2011-12-28 82 views
1

我與jQuery的手風琴菜單的工作,發現父母子女導航問題,需要緊急幫助,感謝jQuery的手風琴摺疊和展開問題(親子中心)

我完全一個父菜單和其擴大孩子,然後單擊標題以使其崩潰。然後我展開另一個標題,當我回到點擊第一個標題時,子菜單沒有崩潰。有沒有辦法在選擇另一個父標題時摺疊一個父標的所有子標題?

謝謝:)

這裏是我的代碼

<div id="accordion"> 
    <h3><a>Link One - First Level</a></h3> 
    <div class="accordionSecond">  
     <h6><a href="#">Second Level</a></h6> 
     <div class="accordionLink"> 
     <a href="1.html">1.html</a> 
     <a href="2.html">2.html</a> 
     <a href="3.html">3.html</a> 
     <a href="4.html">4.html</a> 
     </div> 
    </div> 

    <h3><a>Link Two - First Level</a></h3> 
    <div class="accordionSecond">  
     <h6><a href="#">Second Level</a></h6> 
     <div class="accordionLink"> 
     <a href="1.html">1.html</a> 
     <a href="2.html">2.html</a> 
     <a href="3.html">3.html</a> 
     <a href="4.html">4.html</a> 
     </div> 
    </div>  

</div> 

這裏是小腳本線

<script> 
    $(document).ready(function() { 
    $("#accordion").accordion({active: true, collapsible: true, header: "h3", autoHeight: false, navigation: true, event: 'mouseup'}); 
    $(".accordionSecond").accordion({active: true, collapsible: true, header: "h6", autoHeight: false, navigation: true,event: 'mouseup'}); 
    }); 
    </script> 

回答

2

你想進軍changestart事件父手風琴。在這裏,你可以摺疊任何兒童手風琴:

$("#accordion").accordion({ 
    active: true, 
    collapsible: true, 
    header: "h3", 
    autoHeight: false, 
    navigation: true, 
    event: 'mouseup', 
    changestart: function (event, ui) { 
     ui.oldContent.accordion("activate", false); 
    } 
}); 

使用activate方法,並把它false告訴手風琴摺疊所有部分。

例子:http://jsfiddle.net/p2h8V/

+0

感謝的人!!!!我修好了,感謝一百萬。新年快樂。 – 2011-12-28 23:21:21

+0

我可以問你一件事嗎?你知道如何禁用該頁面上的鏈接嗎? – 2011-12-28 23:22:36

+0

我想我找到了解決方案 jQuery(「a [href $ ='」+ path +「'」「)。removeAttr('href'); 感謝您的幫助,安德魯。 – 2011-12-28 23:30:17