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 brows开发者_如何学编程er solution, and i imagine jquery already has one?
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.
time = 1000; // time in ms to fade from 0.1 to 1
$("#id").fadeTo(0, 0.1).fadeTo(time, 1)
You can set the opacity using css
then begin the fadeIn
E.g.
yourElement.css('opacity', .1).fadeIn();
精彩评论