jQuery - How do I fadein a partially transparent div and retain the opacity?
My div is Opacity:0.7 and filter:alpha(opacity=70);
Fading out works fine
Fading in, it fades all the way to 1 and so is no longer transparent.
How can I fade it in to 0.7?
I tried a .fadeIn followed by .animate but 开发者_如何学运维.animate errors as the div is still display:none at that point.
You want to use fadeTo
:
// When you want to fade in:
$("div").fadeTo( "slow", 0.7 );
// When you want to fade out:
$("div").fadeOut();
Maybe this can help.
http://hv-designs.co.uk/2010/01/13/learn-how-to-add-a-jquery-fade-in-and-out-effect/
What can i do with this code your about to give me? Basically its a fade in fade out effect. The effect fades an element to 50% on arrival of the website, then when you hover over it, it fades to 100%. The effect can be assigned to basically anything in a website wether it be an image, text, a link or even a div.
精彩评论