English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery effect slideUp() method

jQuery Effect Methods

The slideUp() method hides the selected element in a sliding manner.

Note:Hidden elements will no longer affect the page layout.

This method is usually used withslideDown()Methods can be used together.

Syntax:

$(selector).slideUp(duration, easing, callback)

Instance

When clicking "#my-Div" hides the " .panel" on the page when this example is clicked:

$("#my-Div").click(function(){
  $(".panel").slideUp();
});
Test to see‹/›

Slide up all <p> elements when the button is clicked:

$("button").click(function(){
  $("p").slideUp();
});
Test to see‹/›

UsedurationParameters:

$("button").click(function(){
  $("p").slideUp(1500);
});
Test to see‹/›

UsecallbackParameters:

$("button").click(function(){
  $("div").slideUp(1500, function(){
    alert("Slide up completed!");
  });
});
Test to see‹/›

Use a slow duration and linear easing to slide up all " .panel":

$("#my-Div").click(function(){
  $(".panel").slideUp("slow", "linear");
});
Test to see‹/›

Animate all spans (in this example, words) to slide quickly, in200毫秒内完成每个动画:

$("button").click(function(){
  -child
    $(this).prev().slideUp("fast", arguments.callee);
  });
});
Test to see‹/›

Parameter Value

ParameterDescription
durationAn optional value to determine how long the sliding effect will last. The preset value is400 milliseconds

Possible values:

  • milliseconds (e.g.,100,500,2(e.g., 1000, 2000, etc.)

  • "fast"

  • "slow"

easingAn optional string that specifies the speed of the element at different points in the animation. The default value is "swing"

Possible values:

  • "swing"-At the beginning/Move slower at the end and faster in the middle

  • "linear"-Move at a constant speed

callbackA function called once the slideUp() method is completed, for each selected element

jQuery Effect Methods