Easy Tutorial
❮ Api Position Api Focusable Selector ❯

jQuery UI Example - Hide

Hide matched elements with custom effects.

For more details about the .hide() method, please refer to the API documentation .hide().

.hide() Demonstration

Click the button to preview the effect.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Effects - .hide() Demonstration</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.9.1.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
  <style>
  .toggler { width: 500px; height: 200px; }
  #button { padding: .5em 1em; text-decoration: none; }
  #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
  #effect h3 { margin: 0; padding: 0.4em; text-align: center; }
  </style>
  <script>
  $(function() {
    // Run the currently selected effect
    function runEffect() {
      // Get effect type from select menu value
      var selectedEffect = $( "#effectTypes" ).val();

      // Most effect types need no options
      var options = {};
      // Some effects have required parameters
      if ( selectedEffect === "scale" ) {
        options = { percent: 0 };
      } else if ( selectedEffect === "size" ) {
        options = { to: { width: 200, height: 60 } };
      }

      // Run the effect
      $( "#effect" ).hide( selectedEffect, options, 1000, callback );
    };

    // Callback function
    function callback() {
      setTimeout(function() {
        $( "#effect" ).removeAttr( "style" ).hide().fadeIn();
      }, 1000 );
    };

    // Set effect from select menu value
    $( "#button" ).click(function() {
      runEffect();
      return false;
    });
  });
  </script>
</head>
<body>

<div class="toggler">
  <div id="effect" class="ui-widget-content ui-corner-all">
    <h3 class="ui-widget-header ui-corner-all">Hide</h3>
    <p>
      Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede. Nulla lorem metus, adipiscing ut, luctus sed, hendrerit vitae, mi.
    </p>
  </div>
</div>

<select name="effects" id="effectTypes">
  <option value="blind">Blind Effect</option>
  <option value="bounce">Bounce Effect</option>

<option value="clip">Clip Effect</option> <option value="drop">Drop Effect</option> <option value="explode">Explode Effect</option> <option value="fold">Fold Effect</option> <option value="highlight">Highlight Effect</option> <option value="puff">Puff Effect</option> <option value="pulsate">Pulsate Effect</option> <option value="scale">Scale Effect</option> <option value="shake">Shake Effect</option> <option value="size">Size Effect</option> <option value="slide">Slide Effect</option> </select>

<a href="#" id="button" class="ui-state-default ui-corner-all">Run Effect</a>

</body> </html>

View Demo

❮ Api Position Api Focusable Selector ❯