I have this script:
$("#teaser ul.buttons li").mouseover(function()
{
$("a",this).animate({ left: '0' },350);
}).mouseout(function()
{
$("a",this).animate({ left: '-11px' },350);
});
But when i now hover over the a element. The mouseover and mouseout going continu. How can i change this script. That when i hover of the a element. That the mouseout launch when i hover off the element.
jQuery mouseout() MethodThe mouseout event occurs when the mouse pointer leaves the selected element. The mouseout() method triggers the mouseout event, or attaches a function to run when a mouseout event occurs.
The mouseover event occurs when the mouse pointer is over the selected element. The mouseover() method triggers the mouseover event, or attaches a function to run when a mouseover event occurs.
This means that mouseleave is fired when the pointer has exited the element and all of its descendants, whereas mouseout is fired when the pointer leaves the element or leaves one of the element's descendants (even if the pointer is still within the element).
The mouseout event is fired at an Element when a pointing device (usually a mouse) is used to move the cursor so that it is no longer contained within the element or one of its children.
use mouseenter
and mouseleave
instead of mouseover
and mouseout
Is http://jsfiddle.net/BBUJ7/ what you are looking for? I changed the mouseover
and mouseout
to hover since you mentioned hovering in the question and added a {position:relative}
CSS rule.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With