Search code examples
drop-down-menunavbarbootstrap-5

Web-page Menu icon Not getting clicked after collapsing


I have a collapse class applied on navbar but it is not working well. The button gets clicked but menu is not displayed.

Following is the code for the complete navbar:

<nav class="navbar navbar-expand-md navbar-light bg-light">
        <a class="navbar-brand" href="#"><span class="glyphicon glyphicon-fire"></span>Responsive Design</a>
        <button class="navbar-toggler" 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>
      
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
          <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
              <a class="nav-link" href="#" style="text-decoration:none;">Home <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#" style="text-decoration:none;">Link</a>
            </li>
            <li class="nav-item dropdown">
              <a style="text-decoration:none;" class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Services
              </a>
              <ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="navbarDarkDropdownMenuLink">
                <li><a class="dropdown-item" href="#">Web Design</a></li>
                <li><a class="dropdown-item" href="#">IOS Development</a></li>
                <li><hr class="dropdown-divider"></li>
                <li><a class="dropdown-item" href="#">SEO</a></li>
              </ul>
            </li>
            <li class="nav-item">
              <a class="nav-link disabled" href="#">Disabled</a>
            </li>
          </ul>
          <form class="navbar-form navbar-right d-flex">
            <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
            <button class="btn btn-success my-2 my-sm-0" type="submit">Search</button>
          </form>
        </div>
      </nav>

enter image description here


Solution

  • Bootstrap 5 contains data-bs-toggle instead of data-toggle.