I have a tag that appears on an image when the mouse enters the image. When I want to go on the link with the mouse the link logically disappears because i used .mouseleave() function to hide the link when the mouse leaves the image.
I thought to do a conditional test for the .mouseleave() as follow:
if(!$("#linkId").mouseenter()){
//...
}
I tried with .not().mousenter() instead of ! not
But it does not work.. When I enter on the link, it stays and it it never leaves…
Thank you
Sam
Put both, the link and the image in a container and assign the event handler to the container instead. You can position the link with CSS.
As the link and the image are children of the parent, the
mouseleaveevent is not triggered when you hover over the link.Example:
HTML:
CSS:
JavaScript:
DEMO
$("#linkId").mouseenter()is not doing what you think it does. It does not test whether the mouse is over the link or not, it generates amouseenterevent on the link.