jQuery hide()Method

jQuery 效果方法jQuery Effect Methods

Example

Hide all <p> elements:

$("button").click(function(){ $("p").hide(); });

Try it yourself »

Definition and Usage

The hide() method hides the selected elements.

Tip:This is similar to the CSS property display:none.

Note:Hidden elements will not be fully displayed (they no longer affect the page layout).

Tip:To display hidden elements, see show()method.

Syntax

$(selector).hide(speed,easing,callback)

Parameter Description
speed Optional. Specifies the speed of the hide effect.

Possible values:

  • Milliseconds
  • "slow"
  • "fast"
easing Optional. Specifies the speed of the element at different points in the animation. Default value is "swing".

Possible values:

  • "swing" - moves slowly at the beginning/end, moves fast in the middle
  • "linear" - moves at a constant speed
Tip:More easing functions are available in extension plugins.
callback Optional. The function to execute after the hide() method has finished executing.

To learn more about callback, please visit ourjQuery Callbackthis chapter.



实例

More Examples

hide() - Using the speed parameter
How to use the speed parameter when hiding/showing elements.

hide() - Using the callback parameter
How to use the callback parameter when hiding/showing elements.


jQuery 效果方法jQuery Effect Methods

Other Extensions