English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The slideToggle() method inslideUp()andslideDown()Switch between methods.
This method checks the visibility of the selected element:
If the element is initially displayed, it will be hidden
If the element is initially hidden, it will be displayed
Note:Hidden elements will no longer affect the page layout.
$(selector).slideToggle(duration, easing, callback)
Toggle between moving up and down on all <p> elements when the button is clicked:
$("button").click(function() { $("p").slideToggle(); });Test and see‹/›
UsedurationParameters:
$("button").click(function() { $("p").slideToggle();1500); });Test and see‹/›
UsecallbackParameters:
$("button").click(function() { $("div").slideToggle();1500, function() { alert("Slide toggle effect completed!!!"); }); });Test and see‹/›
Use slow duration and linear easing to toggle all " .panel":
$("#my-Div").click(function(){ $(".panel").slideToggle("slow", "linear"); });Test and see‹/›
Parameter | Description |
---|---|
duration | (Optional) Determines how long the sliding effect will last. The preset value is400 milliseconds Possible values:
|
easing | (Optional) A string that specifies the speed of the element at different points of the animation. The default value is "swing" Possible values:
|
callback | (Optional) This function is called once the slideToggle() method is completed, for each selected element |