jQuery toggle () method
Examples
Toggle between hiding and showing at all <p> elements:
$("p").toggle();
});
try it"
Definition and Usage
toggle () method on the selected elements hide () and show () to switch between.
This method checks the selected element visible. If an element is hidden, run the show (), if an element is visible, then run the hide () - This will cause the effect of A handover.
Note: The hidden element is not completely displayed (no longer affects the layout of the page).
Tip: This method can be used to switch between custom functions.
grammar
参数 | 描述 |
---|---|
speed | 可选。规定隐藏/显示效果的速度。 可能的值:
|
easing | 可选。规定在动画的不同点上元素的速度。默认值为 "swing"。 可能的值:
|
callback | 可选。toggle() 方法执行完之后,要执行的函数。
如需学习更多有关 callback 的内容,请访问我们的 jQuery Callback 这一章。 |
More examples
toggle () - use speed parameter
How to use speed parameter to specify the hide / show the speed of the effect.
toggle () - the use of callback parameters
When the Hide / Show to switch between effects, how to use the callback parameter.