I have a piece of code that basically says: if you roll over this , then the other thing appears and if you roll out then it will disappear.
The problem is that if I take the mouse and roll over/out too many times then the elements appears/disappears too many times (because I have created a lot of events for it by mistake)
my code looks like this:
$('div.accordionContent').mouseenter(function()
{
$(this).find(".something").animate({left: 0}, 300)}).mouseleave(function() {
$(this).find(".something").animate({
left: -200}, 500);;
});
How do I tell it to avoid multiple hovering?
I use jQuery 1.4.3 if that helps..
The onmouseout event occurs when the mouse pointer is moved out of an element, or out of one of its children.
The mouseenter event is fired at an Element when a pointing device (usually a mouse) is initially moved so that its hotspot is within the element at which the event was fired.
The mouseleave event occurs when the mouse pointer leaves the selected element. The mouseleave() method triggers the mouseleave event, or attaches a function to run when a mouseleave event occurs. Note: Unlike the mouseout event, the mouseleave event only triggers when the mouse pointer leaves the selected elements.
The onmouseenter event occurs when the mouse pointer is moved onto an element. Tip: This event is often used together with the onmouseleave event, which occurs when the mouse pointer is moved out of an element. Tip: The onmouseenter event is similar to the onmouseover event.
Rather than avoiding multiple triggering, try stopping the animation before starting another.
$('div.accordionContent').mouseenter(function() {
$(this).find(".something").stop().animate(...)
});
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