One way to do this would be to add a class to block the hover, and then remove it when you close the dropdown. You could then put some .css on the hover pseudo class for that class that would block the hover class.
Something like this:
#minicart {display: 'none'}
#minicart:hover {display: 'block'}
#minicart.noHoverCss:hover {display: ''}
Add the noHoverCss
to the cart in openMinicart
and remove it in closeMinicart
.
You could also remove it with some delay after closeMinicart
is done so the user has some time to move their mouse away without triggering the hover.
EDIT TWO:
The other thing you can do is take advantage of the fact that inline .css trumps .css from a style sheet. Instead of using a css class (open
) to set display: block
, do it inline. Similarly, when you exit, set the css to display : none
to force the dropdown to hide, then, after a timeout, set the css to display : ''
to restore your default hovering behavior.
Here's an updated fiddle: fiddle