I'm trying to make table rows collapse if they contain no data. The rows get changed from within a JQuery script. I know they collapse if I place the table inside my HTML. I can create many rows and use display:block
or display:none
and the rows collapse/display as expected. Here is the markup:
<table style="border-collapse:collapse;">
<tr style="display:block;">
<td id="someid">Test</td>
<td>Some text</td>
</tr>
</table>
Here is example code I'm using to change the <tr>
:
var newtr = "<tr style='display:none;'><td id='someid'></td><td></td></tr>"
$("td#someid").parent().replaceWith(newtr);
The contents of the rows change, but they don't collapse. I'm using Firebug to see that display:none
is being inserted. Is there something else I'm missing?