如何使用jQuery在动画中添加新行? [英] How to add a new Row in a table with animation using jQuery?

查看:66
本文介绍了如何使用jQuery在动画中添加新行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 函数expandAll(){
这是我在表格中添加新行的操作: $('#myTableID> tbody> tr> td:n-child(2)> div:n-child(2)')。each(function(){
html = $(this).html );
//是否可以用动画
$(this).parent()。parent()。after(< tr>< td colspan ='2'> ;& nbsp;< / td>< td colspan ='15'>+ html +< / td>< / tr>).slideDown('slow');
} );
}

我可以添加新的行,但没有使用 slideDown

解决方案

如果您有JQuery 1.3.2,您可以这样做:

  $(< your row html>)。hide()。insertAfter($(this).parent()。parent())。slideDown('slow') ; 


This is what i am doing to add new Row in table:-

function expandAll(){
        $('#myTableID>tbody>tr>td:nth-child(2)>div:nth-child(2)').each ( function() {
            html = $(this).html();
// Is it possible to add this Row with animation
            $(this).parent().parent().after( "<tr><td colspan='2'>&nbsp;</td><td colspan='15'>" + html + "</td></tr>" ).slideDown('slow');          
        } );
    }

I am able to add new Row, but there is no effect of using slideDown .

解决方案

If you have JQuery 1.3.2, you can do this:

$("<your row html>").hide().insertAfter($(this).parent().parent()).slideDown('slow');

这篇关于如何使用jQuery在动画中添加新行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆