2012-08-15 28 views
0

你好,我有2個表...無論如何在jQuery使表@動態與表1相同的寬度?如果我能在表2中的td的寬度是表1的寬度......他們會排隊完美...謝謝jQuery同步表格寬度在2表之間

<table id="t1" align="center" class="data_table" style="border-bottom-style: none; margin-bottom: 0px;">  
    <tr>   
     <th>   
     </th>  
    </tr> 
</table> 
<table id="t2" align="center" class="data_table" style="border-top-style: none; margin-top: 0px;">  
    <tr>   
     <th colspan="9 title="Source of Repair (SOR) Remarks">SOR Remarks</th> 
    </tr> 
    <tr>   
     <td width="845px" colspan="9">    
      <textarea name="mcRemark" rows="7" cols="100" scrolling="auto">${mcRemark} </textarea>   
     </td>  
    </tr> 
</table> 

回答

1

嘗試:

 $('#t2').width($('#t1').width()); 

 $('#t2 td').width($('#t1').width()); 

我沒有承諾你正在尋找哪種替代方案。 祝你好運。

+0

你可能想修正'.widht()';)中的拼寫錯誤, – Archer 2012-08-15 16:52:11

0

也許你也應該考慮開始使用colgroup,在那裏你可以定義所有列應繼承的任何自定義樣式。所以,如果你堅持這兩個表的設置,那麼它應該像一個魅力。