New to JQuery. I'm trying to make a menu where the links appear in a div that's in the same position when one of the categories in the menu is hovered over. I want the menu to stay open and disappear when the mouse leaves the menu. The problem I'm having is that every time "projects" is hovered over, none of the other menu categories open. I think this has something to do with "mouseleave" but I can't figure out the fix.
HTML:
<nav>
<ul>
<li class="menuItem">
<a id="press" href="#">Press</a>
</li>
<li class="menuItem">
<a id="projects" href="#">Projects</a>
</li>
<li class="menuItem">
<a id="contact" href="#">Contact</a>
</li>
</ul>
<div class="wing" id="pressWing">
<ul>
<li><a href="">Link 1</a></li>
<li><a href="">Link 2</a></li>
</ul>
</div>
<div class="wing" id="contactWing">
<ul>
<li><a href="">Contact 1</a></li>
<li><a href="">Contact 2</a></li>
</ul>
</div>
<div class="wing" id="projectsWing">
<ul>
<li><a href="">Project 1</a></li>
<li><a href="">Project 2</a></li>
</ul>
</div>
</nav>
jQuery:
$(function() {
$('#contact').hover(function() {
$('#contactWing').show();
});
$('#contactWing').mouseleave(function() {
$('#contactWing').hide();
})
$('#projects').hover(function() {
$('#projectsWing').show();
});
$('#projectsWing').mouseleave(function() {
$('#projectsWing').hide();
})
$('#press').hover(function() {
$('#pressWing').show();
});
$('#pressWing').mouseleave(function() {
$('#pressWing').hide();
})
});
Here is the fiddle: https://codepen.io/maris170/pen/pogEXap