Nick
Nick

Reputation: 171

How to "fix" the slide function in jquery

I have run into a problem with jquerys native slide function, i really like what it does and everything, but for some reason it seems to count the amount of times you hover over it (when you use the .hover as aposed to determining if you are still hovered over it. for instance: live demo. you will notice that if you hover over, remove, then hover over again in quick succession, there will be an issue with what seems to be lag time, does anyone know a way to resolve this? I cant seem to find anything that specifically adresses this issue.

heres the code, for those to skeptic to click on the link, or something:

html:

<div id="click">
    <div id="box"></div>
</div>

css:

  #box { 
    background:#de9a44;
    width:80px; 
    height:60px; 
    display:none; 
    position:absolute;
    left: 0;
    bottom: 0;
}

#click {
    width:80px; 
    height:60px; 
    border:1px solid #cc0001; 
    background:transparent; 
    position:absolute; 
    top:0; 
} 

jquery:

$("#click").hover(function () {
    $("#box").slideToggle("slow");
});

Upvotes: 1

Views: 262

Answers (1)

martincarlin87
martincarlin87

Reputation: 11062

try this:

$("#click").hover(function () {
    $("#box").stop().slideToggle("slow");
});

Upvotes: 2

Related Questions