I use jquery 1.3.2. I try to write simple jquery to the ajax cart implemented on my website.
There are functions ajaxCartOpenCart() – opens cart block (simply unhides it) and ajaxCartCloseCart().
I added simple code that after adding to the cart, unhides cart block, waits for 4 seconds and closes cart block.
ajaxCartOpenCart();
setTimeout(function() {
ajaxCartCloseCart()
}, 4000);
The problem: I need to create a condition that says – if during this time of 4 sec. a mouse enters #cart-block, then don’t close it and wait until mouse leaves. Else count 4 sec and close cart.
Thank you very much for help.
You can clear the timeout and then call the ajax function when the mouse leaves. Something like: