Dropdown Bootstrap does not work [closed]

0

I had made a menu using Bootstrap and it was working perfectly, but I needed to add a dropdown, and apparently it does not display any errors ... But nothing happens by clicking the menu.

      [![<div class="ma][1]][1]sthead">
    <nav>
    <ul class="nav nav-justified">
        <li><a href="index.html">Home</a></li>
        <li><a href="about.html">About</a></li>
        <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Products<span class="caret"></span></a></li>
                    <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
          <li class="active"><a href="#">Action</a></li>
          <li><a href="#">Another action</a></li>
          <li><a href="#">Something else here</a></li>
          <li role="separator" class="divider"></li>
          <li><a href="#">Separated link</a></li>
                    </ul>
        <li><a href="buy.html">Where to Buy</a></li>
        <li><a href="#">Contact Us</a></li>
      </ul>
    </nav>
  </div>

The bootstrap .css and .js files are also correctly pointed to the page.

<link rel="stylesheet" type="text/css" href="css/bootstrap.css">

    
asked by anonymous 03.05.2017 / 16:03

1 answer

3

It does not work because you added the dropdown menu outside the li element. Just insert it that will work perfectly.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

<div class="ma][1]][1]sthead">
  <nav>
    <ul class="nav nav-justified">
      <li><a href="index.html">Home</a></li>
      <li><a href="about.html">About</a></li>
      <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Products<span class="caret"></span></a>
        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
          <li class="active"><a href="#">Action</a></li>
          <li><a href="#">Another action</a></li>
          <li><a href="#">Something else here</a></li>
          <li role="separator" class="divider"></li>
          <li><a href="#">Separated link</a></li>
        </ul>
      </li>

      <li><a href="buy.html">Where to Buy</a></li>
      <li><a href="#">Contact Us</a></li>
    </ul>
  </nav>
</div>
    
03.05.2017 / 16:09