I'm looking to fadeIn() a div that starts of on opacity: 0.1
or (filter: alpha(opacity = 10)
in ie).
I know i can do .animate({css....
with an if(supports opacity)
but i'm looking for a quick and easy cross browser solution, and i imagine jquery already has one?
The . fadeTo() method animates the opacity of the matched elements. It is similar to the . fadeIn() method but that method unhides the element and always fades to 100% opacity.
jQuery fadeIn() Method The fadeIn() method gradually changes the opacity, for selected elements, from hidden to visible (fading effect). Note: Hidden elements will not be displayed at all (no longer affects the layout of the page). Tip: This method is often used together with the fadeOut() method.
Definition and Usage. The fadeTo() method gradually changes the opacity, for selected elements, to a specified opacity (fading effect).
You can do this using .animate()
:
.animate({ opacity: 1 });
There no need to check $.support.opacity
, it'll use the alpha filter version if needed, jQuery normalizes this internally. To be clear, this supports all browsers, including IE. You can test it here.
Edit: re-reading your question it seems these styles may be in the stylesheet, not set by .css()
, in which case just add a zoom: 1
for IE to fade correctly, you can view a demo of that here. You can see how the guts of it work here.
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