You can solve this without JS, with pure css.
HTML
<div id="button">
hover me
</div>
<div id="my-menu">
my menu
</div>
CSS
#my-menu, #button{
padding: 5px;
border: 1px solid #000;
}
#my-menu{
display: none;
}
#button:hover + #my-menu,
#my-menu:hover{
display: block;
}
Here is a JSFiddle: http://jsfiddle.net/p8pqquc9/
You will have a problem with this solution, if the menu is not directly next to the button and you have to leave the :hover state. In this case the only solution is to set a timeout with js or to use the onclick event.
solved How I can showing div element after I hover another div? [closed]