1
Why don’t you open the submenu in this menu I implemented, I can’t find the error. Anyone knows?
Bootstrap v3.3.7 jQuery v3.1.1
<!DOCTYPE html>
<html>
<head>
<title>Menu</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link type="text/css" href="../../resources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="../../resources/js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="../../resources/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#" style="padding: 5px 15px;"><img src="#" width="160"></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="#">Link 1</span></a></li>
<li><a href="#">Link 2</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Link 3 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Link 3.1</a>
<ul class="dropdown-menu">
<li><a href="#">Link 3.1.1</a></li>
<li><a href="#">Link 3.1.2</a></li>
<li><a href="#">Link 3.1.3</a></li>
</ul>
</li>
<li><a href="#">Link 3.2</a></li>
<li><a href="#">Link 3.3</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
In your example also does not work, in case I need to open the submenu of the submenu, ie Link 3.1.1
– Alisson Hoepers
I had not seen that there were 3 levels, I edited my answer I hope to have helped.
– Mauricio Ferraz
Ball show, solved my problem. Thanks, hugs!
– Alisson Hoepers
@Alisson just be careful with this solution because it doesn’t work well on mobile devices as it uses the
:hover
to open the submenus it does not work well with touch screens, where you will not have a cursor– Leandro Godoy Rosa
@Leandrogodoyrosa, ola Leandro, you have some code on how to do it in a way that works also on mobile device?
– Mauricio Ferraz