I have a menu where I display my dropdown on hover. All the elements in this menu are clickable, but also the parent's menu item. I'd like to hide the dropdown-menu when I click on one of the menu items, including the main one (the parent).
At moment, when I click on the parent, it triggers the "open" class, but I don't know what should I do to override that.
<div class="collapse navbar-collapse" id="navbar" ng-controller="HeaderCtrl">
<ul class="nav navbar-nav navbar-right" style="font-weight:bold;">
<li id="parent" class="dropdown desktop">
<a href="#" ng-click="$event.preventDefault();gotoElement('services')" data-toggle="dropdown" class="dropdown-toggle">{{'MENU_SERVICES' | translate}}<b class="caret"></b></a>
<ul class="dropdown-menu" style="background-color:black;">
<li><a href="/services/weddings">{{'CATEGORY_WEDDINGS' | translate}}</a></li>
<li><a href="/services/session">{{'CATEGORY_SHOOTING' | translate}}</a></li>
<li><a href="/services/course">{{'CATEGORY_INTERNSHIPS' | translate}}</a></li>
<li><a href="/services/prints">{{'CATEGORY_PRINTS' | translate}}</a></li>
</ul>
</li>
</ul>
</div>
That's the css part to display my dropdown on hover :
@media screen and (min-width: 768px) {
.dropdown:hover>.dropdown-menu {
display: block;
}
}
I was thinking of doing something like that on the parent click (of course, it's not the solution) : $('#parent').removeClass('open');