其实我面临的一些问题,以得到一个引导手风琴的下拉菜单内工作。我用Google搜索了很多,也在这里找到了一些StackOverflow的线程,但他们是几年前的,并根据自举3或引导2.像这样的位置:Twitter Bootstrap: How to create a dropdown button with an accordion inside it?
任何人可以帮助我在这里还是有一个引导下拉菜单里面工作手风琴的解决方案。
<nav class="navbar navbar-expand-md">
<ul class="navbar-nav">
<li class="nav-item mega-dropdown-menu">
<a class="nav-link" href="#" id="dropdown01"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Test</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<nav class="navbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">Accordion</a>
<div id="collapseExample" class="collapse">
<ul class="navbar-nav">
<li class="nav-link">
<a class="nav-link" href="#">
Accordion Link 1
</a>
</li>
<li class="nav-link">
<a class="nav-link" href="#">
Accordion Link 2
</a>
</li>
</ul>
</div>
</li>
</ul>
</nav>
</div>
</li>
</ul>
</nav>
诀窍保持导航栏下拉开上点击是使用<form>
标签。因此,如果你把一个<form>
它将如期望在里面工作的手风琴。
<div class="collapse navbar-collapse" id="navbarContent">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu">
<form class="accordion" id="accordionExample">
<div>
<a class="nav-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Item #1
</a>
<div id="collapseOne" class="collapse px-3 show" data-parent="#accordionExample">
Collapse 1 content
</div>
</div>
<div>
<a class="nav-link" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Item #2
</a>
<div id="collapseTwo" class="collapse px-3" data-parent="#accordionExample">
Collapse 2 content...
</div>
</div>
<div>
<a class="nav-link" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
Item #3
</a>
<div id="collapseThree" class="collapse px-3" data-parent="#accordionExample">
Collapse 3 content...
</div>
</div>
</form>
</div>
</li>
</ul>
</div>
但是:四联zxsw POI
尝试这个
https://www.codeply.com/go/F8iQy0MeLa
// Prevent dropdown to be closed when we click on an accordion link
$('.dropdown-accordion').on('click', 'a[data-toggle="collapse"]', function (event) {
$($(this).attr('href')).collapse('toggle');
event.stopPropagation();
});