Are jQuery's hide and slideUp methods equivalent?
Asked Answered
P

3

9

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>
Petr answered 13/3, 2011 at 14:57 Comment(0)
R
21

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.

Radiography answered 13/3, 2011 at 15:2 Comment(0)
T
4

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:

Towers answered 13/3, 2011 at 15:3 Comment(0)
H
0
$(function(){
        $(".job-bottom").hide();
        $(".job-top").click(function(){
            $(".job-bottom").slideUp('slow')
            $(this).next(".job-bottom").slideToggle( "slow" );
        });
    });
Hypocaust answered 15/7, 2014 at 6:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.