jQuery API jQuery API 中英文对照版 - jQuery在线查询手册
fadeTo(speed, opacity, callback)
fadeTo(speed,opacity,callback)

把所有匹配元素的不透明度以渐进方式调整到指定的不透明度,并在动画完成后可选地触发一个回调函数。

这个动画只调整元素的不透明度,也就是说所有匹配的元素的高度和宽度不会发生变化。

返回值:jQuery

参数:

  • speed (String|Number): 三种预定速度之一的字符串("slow", "normal", or "fast")或表示动画时长的毫秒数值(如:1000)
  • opacity (Number): 要调整到的不透明度值(0到1之间的数字).
  • callback (Function): (可选) 在动画完成时执行的函数

示例:

$("p").fadeTo("slow", 0.5);

示例:

$("p").fadeTo("slow", 0.5, function(){ alert("Animation Done."); });

 
fadeTo(speed,opacity,callback)

Fade the opacity of all matched elements to a specified opacity and firing an optional callback after completion.

Only the opacity is adjusted for this animation, meaning that all of the matched elements should already have some form of height and width associated with them.

Return value: jQuery
Parameters:

  • speed (String|Number): A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
  • opacity (Number): The opacity to fade to (a number from 0 to 1).
  • callback (Function): (optional) A function to be executed whenever the animation completes, executes once for each element animated against.

Example:

 $("p").fadeTo("slow", 0.5);  

Example:

 $("p").fadeTo("slow", 0.5, function(){     alert("Animation Done.");   });