Are jQuery's hide and slideUp methods equivalent?

左心房为你撑大大i 提交于 2019-12-08 16:12:05

问题


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>

回答1:


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.




回答2:


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()



回答3:


$(function(){
        $(".job-bottom").hide();
        $(".job-top").click(function(){
            $(".job-bottom").slideUp('slow')
            $(this).next(".job-bottom").slideToggle( "slow" );
        });
    });


来源:https://stackoverflow.com/questions/5290152/are-jquerys-hide-and-slideup-methods-equivalent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!