jQuery | fadeTo() with Examples
The fadeTo() is an inbuilt method in jQuery which is used to change the opacity of the selected element.
$(selector).fadeTo(speed, opacity, easing, call_function)
Here selector is the selected element.
Parameter: It accepts four parameters which are specified below-
- speed: It specifies the speed of the fading effect.
- opacity: It specifies to fade and this value should must be in between 0.0 and 1.0.
- easing: It specifies the speed at different point of animation.
- call_function: It is optional parameter and perform a function after performing fadeTo method.
Return Value: It does not return any value.
In the below code, no optional function parameter is passed.
Before clicking on any paragraph-
After clicking on the first and second paragraph-
In the below code, optional function parameter is passed.
Before clicking on the “Click me” button-
After clicking on the “Click me” button-