Nitish Nitish - 6 months ago 23
Javascript Question

td colspan not working for tr with ids

I have a table structure similar to below:

<tr>
<td colspan="5">
TEST
</td>
</tr>
<tr id="abcd_<?php echo $id; ?>" style="display: none">
<td colspan="5">
<span id="hidtb_<?php echo $id; ?>"></span>
</td>
</tr>


The table is within a loop and the value of
$id
changes. The second
tr
is set to
display : block
using javascript. But the
<td colspan="5">
is not covering all the five
<td>
s, instead only one .final output table. Why my
colspan
is not working ?

Answer

This is the problem with display: block.

Please refer the below link http://thedesignspace.net/MT2archives/000376.html#.UUrg3FfCd1u

If you are hiding tr, then use display: table-row instead of display: block to display that tr.

If you are hiding td, then use display: table-cell instead of display: block to display that td.

Use table-row, no block when styling a tr. Perfect!