I have a drop down menu. When the mouse hovers over the parent menu, the child links apear below. The child links remain until the mouse is moved out of the menu element. The hover is removed and the child links dissapear.
I've tried using
$(":hover").blur();
But this is not working.
I'm guessing this is because the item does not have focus applied. Just :hover. Is there a way to remove :hover from jquery?
Thanks
Edit to include html/css
<div class="menu-item">
<button class="dropdown">Dropdown</button>
<div class="dropdown-menu">
<a href="#">Anchor 1</a>
<a href="#">Anchor 2</a>
</div>
</div>
and CSS
.dropdown {
background-color: #04AA6D;
color: white;
font-size: 16px;
}
.menu-item {
position: relative;
display: inline-block;
}
.dropdown-menu {
display: none;
position: absolute;
z-index: 1;
}
.dropdown-menu a {
color: black;
display: block;
}
.menu-item:hover .dropdown-menu {
display: block;
}
This is a sample of the menu. My actual Menu is much bigger. When the visitor hovers over the dropdown the menu show. When they click anyway on the menu I am trying to get the menu to close. As if the hover as been removed.
I have tried blue, mouseout.
The menu still shows after clicking, and only closes after the user scrolls out of the menu, as the menu is so large, this isnt alway possible.
Thanks