简体   繁体   English

Bootstrap列表组菜单在单击时会展开,但不会折叠

[英]Bootstrap list-group menu expands on-click, but does not collapse

I've created a sidebar list-group menu in Bootstrap that expands on the first click, but the second click doesn't collapse the menu back, and clicking on other items simply expands them as well without collapsing anything. 我已经在Bootstrap中创建了一个侧边栏列表组菜单,该菜单在第一次单击时会展开,但是第二次单击不会将菜单向后折叠,并且单击其他项也只会在不折叠任何内容的情况下将它们展开。

    <div id="accordion" class="list-group">
        <a class="list-group-item" data-toggle="collapse" data-parent="#accordion" data-target="#listofOptions">List Header 1</a>
            <div class="list-group-collapse collapse" id="listofOptions">
                <a class="list-group-item" href="#">List Item 1</a>
                <a class="list-group-item" href="#">list Item 2</a>
            </div>
        <a class="list-group-item" data-toggle="collapse" data-parent="#accordion" data-target="#listofOptions2">List Header 2</a>
            <div class="list-group-collapse collapse" id="listofOptions2">
                <a class="list-group-item" href="#">List Item 1</a>
                <a class="list-group-item" href="#">list Item 2</a>
            </div>      
    </div>

I'm using standard bootstrap.min.js and none of my custom JavaScript is touching the .collapse scripts, at least not intentionally. 我使用的是标准bootstrap.min.js,我的自定义JavaScript都没有接触过.collapse脚本,至少不是故意的。

If you have this issue, check and make sure that your CMS isn't duplicating a call to any of the jQuery libraries twice. 如果遇到此问题,请检查并确保CMS不会重复两次调用任何jQuery库。 I found that due to a typo, my header was repeating and the double-call was causing several minor - but annoying - bugs. 我发现由于输入错误,我的标题重复出现,并且两次调用引起了一些较小的但令人讨厌的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM