Search code examples
jqueryanimationfadeinfadeout

jQuery: Fade out from current opacity


I'm fading an object from 0% to 100% on mouseOver, and fade back out to 0% on mouseOut.

When I do a quick mouseIn and mouseOut, the effect "jumps" because mouseOut is fading out from 100% - and because I do a quick mouseIn and mouseOut, the fade in doesn't fade all the way to 100%. Maybe it only fades to 25% or 10%.

My question is: How can I make the fadeout only fading from the specific percentage?

If the fadeIn only gets to 20, the fadeOut should fadeOut from 20.


Solution

  • You could try doing:

    $('#element').animate({opacity:0});
    

    ...instead of fadeOut().