Here’s the jfiddle for what I’m trying to achieve: http://jsfiddle.net/fmvmA/
I have two issues that I’m facing with this example; both of which I figure are related to event propagation. When the mouse enters the container, I’d like to have a div follow the cursor. When the cursor leaves the container, the following div should disappear. This seems like it should be simple… but I’m experiencing problems with the div flickering as you move the mouse, my guess is because the mouse is technically leaving the container when the tooltop div appears.
Additionally, I’d like to be able to click anywhere inside of the container and append a copy of the tooltip div to the position that was clicked. The example is finicky…but if you set the offset so that the tooltip div is no longer overlapping the mouse then you can see it work.
Is there any simple way to achieve my two goals?
It flickers because it triggers mouseout when the tooltip is shown since the #ghost is outside the container.. Move it inside and it should be all set..
DEMO
HTML:
Edit: I noticed a bug when having it inside the container that the
#ghostdoesn’t hide even moving outside container.. so I added an offset to the#ghostso it appears2pxbelow the cursor.JS: