Make a navigation bar with a drop-down menu that will be automatically displayed when you hover over an element of that bar and that when leaving the element is automatically hidden.
I have managed to do almost everything, but when I want the drop-down menu to disappear without having entered it, it does not work for me. Neither my teacher nor I have managed to find the answer and I am agreed that it is something super easy that escapes me.
Then I leave the whole code.
$(document).ready(function (){
$(".dropdown-toggle").on("mouseover", function () {
$(".dropdown-menu").show("slow");
});
$(".dropdown-menu").on("mouseleave", function () {
$(".dropdown-menu").hide("slow");
});
});
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar navbar-inverse" role="navigation">
<div class="navbar-header">
<a href="#" class="dropdown-toggle navbar-brand" data-toggle="dropdown">Menu 1 </a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li><a href="#">Separated link</a></li>
</ul>
<a href="#" class="navbar-brand"> Menu 2</a>
<a href="#" class="navbar-brand"> Menu 3</a>
<a href="#" class="navbar-brand"> Menu 4</a>
</div>
</nav>