jQuery Effect - slideUp() Method

Example

Hide <p> element in a sliding manner:

$(".btn1").click(function(){
  $("p").slideUp();
});

Definition and Usage

Hides the selected element with a sliding effect, if the element is visible.

Syntax

$(selector).slideUp(speed,callback)
Parameter Description
speed

Optional. Specifies the speed of an element from visible to hidden (or vice versa). The default is "normal".

Possible values:

  • Milliseconds (e.g., 1500)
  • "slow"
  • "normal"
  • "fast"

In the process of an element changing from visible to hidden with a set speed, its height will gradually change (creating a sliding effect).

callback

Optional. The function to be executed after the slideUp function is executed.

For more information about callback, please visit our jQuery Callback chapter.

This parameter cannot be set unless the speed parameter is set.

Tips and Comments

Tip:If the element is already hidden, the effect does not produce any change unless a callback function is specified.

More examples

Use the speed parameter
Use the speed parameter to hide and display elements.