Description:
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.
Syntax
.fadeTo( duration, opacity Ex : $(“#div”).fadeToggle(“slow”); 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 belowDuration/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. Example:
Output:
Before button click:
After button click:

Leave A Comment