Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are jQuery's hide and slideUp methods equivalent?

Do slideUp('slow') and hide('slow') result in the same animation effects?

Example Code:

$(document).ready(function(){
  $("#hide").click(function(){
    $("p").hide('slow');
  });
  $("#show").click(function(){
    $("p").show('slow');
  });
});


<p>If you click on the "Hide" button, I will disappear.</p>
<button id="hide">Hide</button>
<button id="show">Show</button>
like image 701
Ben Avatar asked Mar 13 '11 14:03

Ben


2 Answers

No.

.slideUp('slow') animates the height and vertical padding to zero.
.hide('slow') also animates the width, horizontal padding, and opacity to zero.

To see the difference, paste javascript:void($('pre').hide(4000)) in the address bar in this page.

like image 175
SLaks Avatar answered Sep 27 '22 22:09

SLaks


The animation is a little different, - slideUp('slow') basically slides up, nothing else :) - hide('slow') slides up and left at the same time.

In jquery API doc you have good documentation:

  • slideUp()
  • hide()
like image 44
Pizzicato Avatar answered Sep 27 '22 22:09

Pizzicato