javascript 控制 table tr display block 顯示模式時,只對第一個單元格有效

(本文來自 http://www.wilson-loo.com/wordpress/archives/140)javascript

有一個簡單的 table:java

noteinfo_title  wilsol LOCAL - Opera

<table >
 <tr >
 <th>編號</th>
 <th>類型</th>
 <th>詳細</th>
 <th>建立時間</th>
 <th>修改時間</th>
 <th>操做</th>
 </tr>
 
 <tr>
 <td>5</th>
 <td>TECH</th>
 <td>測試內容</th>
 <td>2014−01−10 16:56:31</th>
 <td>−−</th>
 <td>修改 刪除</th>
 </tr>
 
 <tr id="id_dync" style="display:none">
 <td colspan=6>
 <div id=xxxx >測試內容</div>
 </td>
 </tr>
 
</table>

 

但願經過 javascript 控制 第三 行的 tr 隱顯狀態:wordpress

var tr_modifing = document.getElementById( "id_dync" );
tr_modifing.style.display = "block";

這種將 style.display 設置成 block 後, 會出現 只對第一個單元格 td 有效的狀況:測試

noteinfo_title  wilsol LOCAL - Opera_2

緣由是 將 tr.style.display = 「block」 後, 該 tr 就不是普通的 【表格】之【行】了, 而就像普通的 div 同樣普通的塊, 因此下面的 spa

<td colspan=6 >

也會隨着失效, 正確的作法是 code

var tr_modifing = document.getElementById( "id_dync" );
tr_modifing.style.display = "table−row";

即 將 tr 的 顯示模式設置爲 【table-row】blog

相關文章
相關標籤/搜索