skip to Main Content

So I’ve looked at dozens of posts about this kind of issue and haven’t been able to find the answer. I am having an issue with my navbar menu toggle on collapse. When the browser width is smaller, the menu button shows, but clicking on the menu button does nothing. I need it to display the menu list, obviously. Here’s the code:

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar navbar-inverse bg-inverse navbar-toggleable-sm bg-faded navbar-fixed-top">
		<div class="container">
		<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a id="header-initials" class="navbar-brand" href="home">JT</a>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#home">home</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#skills">skills</a>
      </li>
			<li class="nav-item">
        <a class="nav-link" href="#about">about</a>
      </li>
			<li class="nav-item">
        <a class="nav-link" href="#work">work</a>
      </li>
			<li class="nav-item">
        <a class="nav-link" href="#contact">contact</a>
      </li>
    </ul>
  </div>
	</div>
	</nav>

3

Answers


  1. Hi have you added the bootstrap.min.js to your code?
    if not
    add this code after jQuery

    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
    

    hope this helps

    Login or Signup to reply.
  2. Put the <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script> after the <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

    I’ve tested the above changes. It will work.

    Login or Signup to reply.
  3. You have to need call bootstrap.js before closing </body> tag along with other JavaScript file. Example here

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
    
    
    <nav class="navbar navbar-inverse bg-inverse navbar-toggleable-sm bg-faded navbar-fixed-top">
      <div class="container">
        <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
        <a id="header-initials" class="navbar-brand" href="home">JT</a>
    
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
          <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
              <a class="nav-link" href="#home">home</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#skills">skills</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#about">about</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#work">work</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#contact">contact</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search