English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery 效果 fadeOut() 方法

jQuery Effect Methods

fadeOut()方法逐渐将选定元素的不透明度,从可见更改为隐藏。

该方法通常与fadeIn()方法一起使用。

注意:隐藏的元素将不再影响页面的布局。

语法:

$(selector)fadeOut.(duration, easing, callback)

实例

淡出所有<p>元素:

$("button").click(function() {
  $("p").fadeOut();
});
Test and see‹/›

使用duration参数:

$("button").click(function() {
  $("p").fadeOut(1500);
});
Test and see‹/›

使用callback参数:

$("button").click(function() {
  $("div").fadeOut(600, function() {}}
    $("h3).text("Fade OUT complete.");
  });
});
Test and see‹/›

We can implement fade in/fade out effects on any element, for example, simple images:

$("button").click(function() {
  $("img").fadeOut();
});
Test and see‹/›

Parameter Value

ParameterDescription
duration(Optional) Determines how long the fade effect will last. The default value is400 milliseconds

Possible values:

  • milliseconds (e.g.,100,500,2(e.g., 1000, 2000, 3000, etc.)

  • "fast"

  • "slow"

easing(Optional) A string that specifies the speed of the element at different points in the animation. The default value is "swing".

Possible values:

  • "swing"-At the beginning/Move slower at the end and faster in the middle

  • "linear"-Move at a constant speed

callback(Optional) The callback function will be called once for each selected element when the fadeOut() method is completed.

jQuery Effect Methods