Latest web development tutorials

jQuery effects fadeTo () method

jQuery Effect Methods jQuery Effect Methods

Examples

Gradually change all <p> elements Opacity:

$("button").click(function(){
$("p").fadeTo(1000,0.4);
});

try it"

Definition and Usage

fadeTo () method of gradually changing the opacity value of the selected element (fade) specified.

grammar

$(selector).fadeTo(speed,opacity,easing,callback)

参数 描述
speed 必需。规定褪色效果的速度。

可能的值:

  • 毫秒
  • "slow"
  • "fast"
opacity 必需。规定要淡入或淡出的透明度。必须是介于 0.00 与 1.00 之间的数字。
easing 可选。规定在动画的不同点上元素的速度。默认值为 "swing"。

可能的值:

  • "swing" - 在开头/结尾移动慢,在中间移动快
  • "linear" - 匀速移动
提示:扩展插件中提供更多可用的 easing 函数。
callback 可选。fadeTo() 方法执行完之后,要执行的函数。

如需学习更多有关 callback 的内容,请访问我们的 jQuery Callback 这一章。



Examples

More examples

fadeTo () - the use of callback parameters
When the fade in and fade elements, how to use the callback parameter.


jQuery Effect Methods jQuery Effect Methods