JavaScript 参考手册
Style emptyCells 属性
改变空单元格的显示方式
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <script> function show() { document.getElementById("myTable").style.emptyCells = "show"; } function hide() { document.getElementById("myTable").style.emptyCells = "hide"; } </script> </head> <body> <table id="myTable" border="1"> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td></td> </tr> </table> <br> <button type="button" onclick="show()">显示空单元格</button> <button type="button" onclick="hide()">隐藏空单元格</button> <p><b>注意:</b> Internet Explorer 8 及更早版本要支持empty-cells属性必须声明 !DOCTYPE 。</p> </body> </html>
运行结果:
点击运行 »