Bootstrap 4(Jquery?) - 移动菜单中的nav-items不起作用

时间:2017-08-23 14:57:10

标签: javascript jquery twitter-bootstrap bootstrap-4

我使用Bootstrap4制作导航栏,当我打开网站时,菜单中的移动屏幕链接无效。这是我的代码:

<nav class="navbar navbar-expand-sm navbar-dark" style="background-color: #E2BA28">
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#nav-content" aria-controls="nav-content" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <!-- Brand -->
        <a class="navbar-brand" href="https://www.example.com"><img src="logo" width="60" class="d-inline-block align-top" alt=""></a>

        <!-- Links -->
        <div class="collapse navbar-collapse justify-content-end" id="nav-content">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link eak-link" href="https://www.example.com">example</a>
            </li>
            <li class="nav-item">
                <a class="nav-link eak-link" href="https://www.example.com">example</a>
            </li>
            <li class="nav-item">
                <a class="nav-link eak-link" href="#">example</a>
            </li>
            <li class="nav-item">
                <a class="nav-link eak-link" href="https://www.example.com">example</a>
            </li>
            <li class="nav-item">
                <a class="nav-link eak-link eak-abc" href="https://www.example.com">example</a>
            </li>
        </ul>
</nav>

如果确实有帮助我正在使用这个js:

$(document).ready(function(){
      $('.nav-item').hover(function(){
          $(this).toggleClass('animated bounceIn')
      });
});

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

除了在页面的页脚添加bootstrap的js代码之外,您还需要包含jQuery

这是一支工作笔:

CodePen