Style emptyCells 属性

Style 对象参考手册 Style 对象

定义和用法

emptyCells 属性设置或返回是否显示表格中的空单元格的边框和背景。

语法

设置 emptyCells 属性:

Object.style.emptyCells="show|hide|inherit"

返回 emptyCells 属性:

Object.style.emptyCells

描述
show 显示空单元格的边框和背景,即在空单元格周围绘制边框。
hide 隐藏空单元格的边框和背景,即不在空单元格周围绘制边框。
inherit emptyCells 属性的值从父元素继承。


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 emptyCells 属性。

注意:不同浏览器中的默认值不同。在 IE、Chrome 和 Safari 浏览器中,默认值是 "show",而在 Firefox 和 Opera 浏览器中,默认值是 "hide"。

注意:IE7 及更早的版本不支持 emptyCells 属性。IE8 只有规定了 !DOCTYPE 才支持 emptyCells 属性。IE9 支持 emptyCells 属性。


实例

实例

改变空单元格的显示方式:

<html>
<head>
<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()">Show empty cells</button>
<button type="button" onclick="hide()">Hide empty cells</button>

</body>
</html>

尝试一下 »


Style 对象参考手册 Style 对象