English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The fadeIn() method gradually changes the opacity of the selected element from hidden to visible.
This method is usually used withfadeOut()methods are used together.
Note:Hidden elements will no longer affect the page layout.
It is similar tofadeTo()The method is similar, but this method does not cancel the hidden element and can specify the final opacity level.
$selector.fadeIn.(duration, easing, callback)
Fade in <div> elements:
$("button").click(function(){ $("div").fadeIn(); });Test to see‹/›
Fade in all <p> elements:
$("button").click(function(){ $("p").fadeIn(); });Test to see‹/›
UsedurationParameters:
$("button").click(function(){ $("p").fadeIn(1500); });Test to see‹/›
UsecallbackParameters:
$("button").click(function(){ $("div").fadeIn(600, function(){ $("h3).text("Fade in completed."); }); });Test to see‹/›
We can implement fade in/fade out effects on any element, for example, simple images:
$("button").click(function(){ $("img").fadeIn(); });Test to see‹/›
Parameter | Description |
---|---|
duration | (Optional) Determines how long the fade effect will last, can be a string or a number. The default value is400 milliseconds Possible values:
|
easing | (Optional) Specify the speed of the element at different points of the animation. The default value is "swing" Possible values:
|
callback | (Optional) The function to be called after the fadeIn() method completes, called once for each selected element |