Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery Effects fadeTo() method

jQuery Effects fadeTo() method

jQuery effects methods jQuery effects methods

Example

Gradually change the opacity of all

elements:

$

(

"

button

"

)

.

click

(

function

(

)

{

$

(

"

p

"

)

.

fadeTo

(

1000

,

0.4

)

;

}

)

;

Try it »


Definition and Usage

The fadeTo() method gradually changes the opacity of the selected elements to a specified value (a fading effect).

Syntax

$(

selector

).fadeTo(

speed,opacity,easing,callback

)

Parameters Description
speed Required. Specifies the speed of the fading effect.

Possible values:

  • Millisecond
  • "slow"
  • "fast"
  • | | *opacity* | Required. Specifies the opacity to fade to or from. Must be a number between 0.00 and 1.00. | | *easing* | Optional. Specifies the speed of the element at different points in the animation. The default is "swing".

    Possible values:

    **Tip:** More easing functions are available in extension plugins. | | *callback* | Optional. A function to be executed after the fadeTo() method finishes.

    To learn more about callback, please visit our jQuery Callback chapter on callbacks.

    |

    More examples

    fadeTo() - Using the callback parameter
    How to use the callback parameter when fading elements in and out.


    jQuery effects methods jQuery effects methods