I have created a nav menu with bootstrap nav. I have added a small jquery code when i press mobile toggle menu it will close automatically and go destination
but if i have drop down menu in nav. this drop menu now not working. when i press dropdown menu parent for expand its close the menu automatically. and i cant check which menu available in drop down menu so i have tried to add a condition. but its not working.
in dropdown menu parent have class called .dropdown-toggle. if this class available it shouldn't be close automatically
if (jQuery(".navbar-collapse a").val() !== '.dropdown-toggle') {
jQuery('.navbar-collapse a').click(function (e) {
jQuery('.navbar-collapse').collapse('toggle');
});
}
And here the html code
<ul class="nav navbar-nav">
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
</ul>
</li>
</ul>