javascript - 动画表格行滑出或淡入?

标签 javascript css jquery-animate

我偶然发现了这个插件

https://jquery-datatables-row-grouping.googlecode.com/svn/trunk/customization.html

问题是,一切都在 <tr> 中s,我担心你不能为它们制作动画?

真的没有办法吗?明智的 CSS 或 javascript。

例如我想为表格 tr 元素设置动画。

最佳答案

也许一个解决方案可能是这样的:

var animate = function(evt) {
  //we go to the 'tr' tag
  $el = $(evt.currentTarget).parent().parent();
  
  //we hide the 'td's tag 
  $el.find('td').hide(333 , function(){
    // we reduce the height of 'tr' tag
    $el.animate({height : 0} , 777)
  });
  

}
$('button').click(animate);
table {
  border: solid 1px #AAA;
  padding: 3px;
  border-collapse: separate;
}
td {
  height: 50px;
  margin : 3px;
  min-width : 50px;
  border: solid 1px orange;
}
tr {
  height : 55px;
  padding : 12px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <tr>
    <td>a</td><td>b</td><td><button>hide</button></td>
  </tr>
  <tr>
    <td>a</td><td>b</td><td><button>hide</button></td>
  </tr>
  <tr>
    <td>a</td><td>b</td><td><button>hide</button></td>
  </tr>
</table>

关于javascript - 动画表格行滑出或淡入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33517587/

相关文章:

jquery - 使用 jQuery 动画背景图像更改

javascript - 从数组中获取所有单个单词

javascript - 页面加载后显示弹出窗口

javascript - 将列表重新格式化为分组结构

javascript - 如何确保 clickable 运行而不是 td

javascript - 改进 HTML5 视频和 jQuery 代码以提高效率

javascript - 如果选中复选框(单击按钮),如何使表格行突出显示?

c++ - 如何将多个样式类添加到 QWidget

javascript - jQuery 中持续时间长的短距离微妙字体大小动画

css - IE9 - 从 div 中心放大和缩小的 Animate()