I have a jQuery script that controls the opening and closing of the "shopping_cart" div when hovering over the "shopping_button".
$('#shopping_button, .shopping_cart').on('mouseenter',function(){
$(this).css('z-index','300');
$(this).css('visibility','visible');
})
$('#shopping_button, .shopping_cart').on('mouseleave',function(){
$(this).css('z-index','189');
$(this).css('visibility','hidden');
$(this).css('opacity','0');
});
I want the "shopping_cart" to stay open when the mouse leaves, and only close when clicking outside of the div or using a close button inside the "shopping_cart".
Thank you to everyone for your help.
Edited
I added this code to the existing script:
$('html').click(function () {
$('.shopping_cart').css('visibility','hidden');
});
While this successfully closes the window when clicking outside of it, now the "shopping_cart" won't open again when hovering over the "shopping_button". It seems to remain hidden according to the inspect element tool.
$('#shopping_button, .shopping_cart').on('mouseenter',function(){
$(this).css('z-index','300');
$(this).css('visibility','visible'); <---This Remain Hidden
})
Any suggestions?
Sorted
I added this line to the mouseenter function:
$('.shopping_cart').css('visibility','visible');
And it works! Still open to cleaner solutions if anyone has any.
Thanks again for the assistance.