jQuery 的 hide 和 slideUp 方法等效吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5290152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 18:54:53  来源:igfitidea点击:

Are jQuery's hide and slideUp methods equivalent?

jqueryhideshowslidedownslideup

提问by Yosef

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

是否slideUp('slow')hide('slow')导致相同的动画效果?

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>

回答by SLaks

No.

不。

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

.slideUp('slow')动画高度和垂直填充为零。
.hide('slow')还将宽度、水平填充和不透明度设置为零。

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

要查看差异,请粘贴javascript:void($('pre').hide(4000))到此页面的地址栏中。

回答by Pizzicato

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

动画有点不同, - slideUp('slow') 基本上是向上滑动,没有别的 :) - hide('slow') 同时向上和向左滑动。

In jquery API doc you have good documentation:

在 jquery API doc 你有很好的文档:

回答by Kamlesh

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