Let's suppose I have two spearate divs, A and B, which overlap at a corner:
+-----+
| |
| A |
| +-----+
+---| |
| B |
| |
+-----+
I want to trigger an event when the mouse leaves both A and B.
I tried this
$("#a, #b").mouseleave(function() { ... });
But this triggers the event if the mouse leaves either node. I want the event to be triggered once the mouse is not over either node.
Is there an easy way to do this? I had an idea that involved global variables keeping track of the mouse state over each div, but I was hoping for something more elegant.
.offset()
for each#a, #b
, and when the mouse position is no longer over the combined coordinates,$('#a, #b').trigger('mouseleave');
. – Julietjulieta