I am having difficulty with hiding and showing table columns using checkboxes. I need to eliminate the Mars column (in bold) along with its corresponding data (also in bold).
Once the Mars column is removed, I want the Venus column and its data values to be centered in the table.
Check out the example here: http://jsfiddle.net/bL44n3aj/3/
After removing the Mars column, this is the desired output: http://jsfiddle.net/2Lcsc2go/
This is my CSS and HTML code:
td{
border:1px solid #000;
}
th{
border:1px solid red;
font-weight:normal !important;
}
tr.sub-header th{
text-align:center !important;
border:1px solid blue !important;
font-weight:bold !important;
}
tr.sub-header-value td{
text-align:center !important;
font-weight:bold !important;
}
<table width="80%">
<tr>
<th>Produced</th>
<th>Sold</th>
<th>Produced</th>
<th>Sold</th>
</tr>
<tr class="sub-header">
<th colspan="2">Mars</th>
<th colspan="2" scope="colgroup">Venus</th>
</tr>
<tr>
<td>50,000</td>
<td>30,000</td>
<td>100,000</td>
<td>80,000</td>
</tr>
<tr class="sub-header-value">
<td colspan="2">Mars data</td>
<td colspan="2"> Venus data </td>
</tr>
<tr>
<td>10,000</td>
<td>5,000</td>
<td>12,000</td>
<td>9,000</td>
</tr>
<tr class="sub-header-value">
<td colspan="2">Mars data</td>
<td colspan="2">Venus data</td>
</tr>
</table>
<input type="checkbox"> Remove Mars