jQuery Accordion Collapse and Expand Issue (Parent & Child)



我正在使用jQuery Accordion菜单,发现父级和子级导航有问题,需要紧急帮助,谢谢

我完全展开父菜单及其子菜单,然后单击标题以使其折叠。然后我展开另一个标题,当我回去点击第一个标题时,子菜单没有折叠。是否有办法在选择另一个父标题时折叠一个父标题的所有子标题?

谢谢:)

这是我的代码

<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>

您想要访问父手风琴的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,告诉accordion折叠所有的section。

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

最新更新