jQuery fadeToggle() method
Example
Toggle between fading in and fading out different boxes:
$("button").click(function(){
$("#div1").fadeToggle();
});
Try it »
Definition and Usage
The fadeToggle() method toggles between the fadeIn() and fadeOut() fadeIn() and fadeOut() methods.
If elements are hidden (faded out), fadeToggle() shows them with a fade-in effect.
If elements are shown (faded in), fadeToggle() hides them with a fade-out effect.
**Note:** Hidden elements will not be fully displayed (they no longer affect the page's layout).
Syntax
$(
selector
).fadeToggle(
speed,easing,callback
)
| Parameters | Description |
|---|---|
| speed | Optional. Specifies the speed of the fading effect.
Possible values: |
Possible values:
- "swing" - Moves slowly at the beginning/end, and faster in the middle
- "linear" - Moves at a constant speed
如需学习更多有关 callback 的内容,请访问我们的 [jQuery Callback](jquery-callback.html) 这一章。 |
More examples
fadeToggle() - Using the speed parameter
How to use the speed parameter to specify the speed of the fading effect.
fadeToggle() - Using the callback parameter
How to use the callback parameter to execute a function after the fadeToggle() method completes.
jQuery effects methods