我的代码不起作用,但我不知道为什么

时间:2017-10-10 10:11:07

标签: javascript jquery css twitter-bootstrap

我的代码不起作用,但我不知道为什么

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>

1 个答案:

答案 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">