我的代码不起作用,但我不知道为什么
https://jsfiddle.net/byNickSan/p78pacvg/1/
jQuery 2.2.3
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
答案 0 :(得分:0)
将data-target
更改为正确的元素ID。在您的情况下,#bs-example-navbar-collapse-1
是您想要的元素ID:
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false" aria-controls="navbar">