javascript - jQuery 用幻灯片隐藏元素

标签 javascript jquery

我试图隐藏一个完美工作的 div,但我想使用 jQuery slide 用一点动画来隐藏它,而不是立即消失。

$(".hide-reply").click(function(){
    $(this).closest('.media').find('.reply-body').hide();
});

我尝试将行更改为(根据 jQuery 文档)-

$(this).closest('.media').find('.reply-body').hide("slide", { direction: "up" }, 100);

但这会抛出一个Uncaught TypeError: n.easing[this.easing] is not a function 我不确定我是否理解这个错误。

最佳答案

尝试使用 .animate() ,将 height 设置为 0

$("div").animate({
  height:0
}, 1000);
div {
  width:100px;
  height:100px;
  background:blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>

<div></div>

关于javascript - jQuery 用幻灯片隐藏元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35496166/

相关文章:

javascript - 如何修复 ChartJS 中看起来模糊的图表?

javascript - 如何在自定义Object.prototype.xxx函数中获取对象本身?

jquery - 我应该如何停止 "in progress"jquery POST?

javascript - jQuery 同位素表问题,Firefox 除外

javascript - jquery 类型错误 : can't assign to properties of new String

javascript - 如何在 html canvas 元素上绘制一条半透明的线且线上没有点?

javascript - 加载后播放 HTML5 视频

javascript - Angular/Jasmine : spying on method passed to $rootScope. $on 带和不带匿名函数包装器

javascript - 使用javascript在字符串中搜索字符

javascript - 莫里斯图表日自定义问题