Okay, I have changed from using JavaScript to CSS in aligning the column width. But for some reasons it still won't line up. I want every td in a fixed width percentage, and the thead with the same too.
Eg. If you search "cherry" the width will change, but I want it to be fixed. shouldn't it be 40px all the time with the current code?
Thank you very much.
<table id="table-body">
<thead>
<tr>
<th>No.</th>
<th>Name</th>
<th>ad</th>
<th>Tel</th>
<th>Fax</th>
</tr>
</thead>
<tbody>
<tr>
<td>12311</td>
<td>Apple</td>
<td>A1fgsdfgfhynfg</td>
<td>1-11</td>
<td>1-22</td>
</tr>
<tr>
<td>12312</td>
<td>Banana</td>
<td>A2dfgdfgdfgdfg</td>
<td>2-11</td>
<td>2-22</td>
</tr>
<tr>
<td>3Asdqwe</td>
<td>Cherry</td>
<td>A3</td>
<td>3-11</td>
<td>3-22</td>
</tr>
<tr>
<td>12314</td>
<td>Duriaen</td>
<td>A456ghkfghk</td>
<td>4-11</td>
<td>4-22</td>
</tr>
<tr>
<td>12315</td>
<td>Apple</td>
<td>A1uyjmghtd</td>
<td>5-11</td>
<td>5-22</td>
</tr>
<tr>
<td>12316</td>
<td>Banana</td>
<td>A2yukmkfgmufc</td>
<td>6-11</td>
<td>6-22</td>
</tr>
<tr>
<td style="width:70px;">3Asdqwe</td>
<td>Cherry</td>
<td>A3</td>
<td>7-11</td>
<td>7-22</td>
</tr>
<tr>
<td>123117</td>
<td>Duriaen</td>
<td>A4nuftkf</td>
<td>8-11</td>
<td>8-22</td>
</tr>
<tr>
<td>123118</td>
<td>Duriaen</td>
<td>A4</td>
<td>8-11</td>
<td>8-22</td>
</tr>
<tr>
<td>123119</td>
<td>Cherry</td>
<td>Aoikdhpnko</td>
<td>7-11</td>
<td>7-22</td>
</tr>
<tr>
<td>4A</td>
<td>Duriaen</td>
<td>A4ueowrqp</td>
<td>8-11</td>
<td>8-22</td>
</tr>
<tr>
<td>12311</td>
<td>Duriaen</td>
<td>A4zcnnzcxt</td>
<td>8-11</td>
<td>8-22</td>
</tr>
</tbody>
</table>
CSS
#table-body, table.header tr> *:nth-child(1) {width:10px;}
#table-body, table.header tr> *:nth-child(2) {width:10px;}
#table-body, table.header tr> *:nth-child(3) {width:40px;}
#table-body, table.header tr> *:nth-child(4) {width:20px;}
#table-body, table.header tr> *:nth-child(5) {width:20px;}