jQuery fadeTo() method is used to fading the given opacity for the matched/selected element. It is similar to the .fadeIn method but that method unhides the element and always fades to 100% opacity.


.fadeTo( duration, opacity [, complete ] )

Ex : $(“#div”).fadeToggle(“slow”);

Duration/speed  It specifies the speed of the fadein. The valuse may be slow, fast and milliseconds. (default value: 400). Duration are given in milliseconds and higher values indicate slower animations, not faster ones.
Easing  It specifies the easing function to be used for transition (default value: swing).
Callback A function to call once the animation is complete.


From the below code, fadeTo() method will apply opacity of 0.2 to the divFadeBox element. A number between 0 and 1 specifying the target opacity. 


After clicking the “Click to Apply Opacity using .fadeTo()” button, then the blue box will be fadein up to specified opacity (ie., 0.2) as shown below

Before button click:

After button click: