I'm facing an issue with my button and menu functionality. Even though I have coded the menu to hide itself when the mouse leaves, it hides before the mouse even goes over it. Any suggestions on how to resolve this?
function showMenu() {
var menuBar = document.getElementById("menu");
menuBar.style.display = "block";
}
function hideMenu() {
document.getElementById("menu").style.display = "none";
}
<a id="menu_button" onmouseover="showMenu()"><img src="https://i.imgur.com/mRIyhW8.png" class="menu_button" onmouseover="this.src='https://i.imgur.com/zSPpoVX.png'" onmouseout="this.src='https://i.imgur.com/mRIyhW8.png'" /></a>
<div id="menu" onmouseout="hideMenu()">
<ul>
<li>HOME</li>
<li>PORTFOLIO</li>
<li>ABOUT</li>
</ul>
</div>
UPDATE Resolved the issue by adding a z-index: 2; in my CSS. Appreciate your assistance.