English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The fadeToggle() method is available infadeIn()andfadeOut()Switch between methods.
If the selected elements are faded out, fadeToggle() will fade them in.
If the selected elements are faded in, fadeToggle() will fade them out.
Note:Hidden elements will no longer affect the page layout.
$(selector)fadeToggle.(duration, easing, callback)
Toggle fade-in and fade-out between all <p> elements:
$("button").click(function(){ $("p").fadeToggle(); });Test to see‹/›
UsedurationParameters:
$("button").click(function(){ $("p").fadeToggle(1500); });Test to see‹/›
UsecallbackParameters:
$("button").click(function(){ $("div").fadeToggle(1500, function(){} alert("fadeToggle effect completed!!!"); }); });Test to see‹/›
We can implement a fade in and out effect on any element, for example, a simple image:
$("button").click(function(){ $("img").fadeToggle(); });Test to see‹/›
Parameters | Description |
---|---|
duration | (Optional)Determines how long the fade effect will last. The preset value is400 milliseconds Possible values:
|
easing | (Optional)A string that specifies the speed of the element at different points in the animation. The default value is "swing" Possible values:
|
callback | (Optional)This function is called once the fadeToggle() method is completed, for each selected element |