tags:

views:

33

answers:

3

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?

+2  A: 

You can set the opacity using css then begin the fadeIn

E.g.

yourElement.css('opacity', .1).fadeIn();
Matt
A: 
time = 1000; // time in ms to fade from 0.1 to 1
$("#id").fadeTo(0, 0.1).fadeTo(time, 1)
Adam
FYI.. `fadeTo` with duration of 0 is the same as calling `css('opacity', ...)` directly. See [documentation](http://api.jquery.com/fadeTo)
Matt
Ah. good point :) Upvoted your answer.
Adam
+1  A: 

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.

Nick Craver
bloody ie, with the zoom:1 fix i've got it fading brilliant, but when it comes to rest on alpha 100 it suddenly looks awful! Must be something to do with IE's alpha and the transparent png image im using. oh well, i think this can be an embellishment ie users can go without (for now)! thanks for your help
Haroldo