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

jQuery Effect hide() Method

jQuery Effect Methods

hide() method to hide the selected elements.

This method is usually used withshow()methods are used together.

Note:The hidden elements will no longer affect the layout of the page.

Syntax:

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

Example

This example hides paragraphs on the page when the page is clicked:

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

Hide all <p> elements when the button is clicked:

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

UsingdurationParameters:

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

UsingcallbackParameters:

$$("button").click(function(){
  $$("div").hide(1000, function(){
    alert("DIV is hidden");
  });
});
Test to see‹/›

All spans of animation (in this case, words) are hidden quickly, in200 milliseconds to complete each animation:

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

Click more than2Seconds, hide the span element and then remove the span element when hiding:

$("span").click(function() {
  $(this).hide(2(e.g., 1000, 2000, etc.), function() {
    $(this).remove();
  });
});
Test to see‹/›

Parameter Value

ParameterDescription
durationOptional: The duration for which the hide effect will run. The preset value is400 milliseconds

Possible values:

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

  • "swing"

  • "slow"

easingOptional: A 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

callbackOptional: The function called after the hide() method completes, called once for each selected element

jQuery Effect Methods