2009-12-15 29 views
3

這是我在做什麼,以在表中添加新行: -如何使用jQuery在動畫中添加新行?

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');   
     }); 
    } 

我能夠添加新行,但沒有使用了slideDown的效果。

+0

怎麼樣,如果你改變的動畫時,被添加元素的高度。 – 2009-12-15 14:18:23

+0

@詹姆斯:那是可以接受的。怎麼做? – 2009-12-16 04:39:22

回答

6

如果你有JQuery的1.3.2,你可以這樣做:

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