6

I want table rows to disappear (by animating their height to 0px and opacity to 0). I'm using the following

$('#somecellelement').closest('tr').children('td').css('overflow','hidden');
$('#somecellelement').closest('tr').children('td').animate({
    height: '0px',
    opacity: 0
},500);

Where #somecellelement is something contained in cells of rows I want hidden. Opacity is animating correctly but the table row doesn't get smaller. If I set height: 500px then it works, but I need the row to disappear.

I cannot remove the element from DOM, though, due to scripts expecting values from form elements in those rows.

Jawa
  • 2,336
  • 6
  • 34
  • 39
A-OK
  • 3,184
  • 10
  • 34
  • 42
  • Is there a reason not stated that you are animating the td element instead of #somecellelement directly? The problem you're having is tr and td aren't set to display type of block which causes an issue with trying to set their height to 0. – Doozer Blake Sep 27 '11 at 04:17
  • #somecellelement is not supposed to be animated. it's just an whose parent row needs to be hidden. – A-OK Sep 27 '11 at 04:21
  • 1
    Well, you're going to have issues achieving a height animation on a tr or td is why I asked, they just don't appear to work. The 2 solutions posted below are I assume not doing what you're looking for specifically. I'm reading it that you want it to animate the height up until the row disappears. – Doozer Blake Sep 27 '11 at 04:24
  • Yes, exactly. And I need to use