Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery fadeIn() from opacity: 0.1 - possible?

Tags:

jquery

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?

like image 768
Haroldo Avatar asked Jul 01 '10 19:07

Haroldo


People also ask

What is value of opacity parameter in FADE TO () method?

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.

What is fadeIn function in jQuery?

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.

What is fadeTo?

Definition and Usage. The fadeTo() method gradually changes the opacity, for selected elements, to a specified opacity (fading effect).


1 Answers

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.

like image 65
Nick Craver Avatar answered Oct 04 '22 04:10

Nick Craver