HTML DOM Style emptyCells 屬性
定義和用法
emptyCells 屬性設置或返回是否顯示表格中的空單元格的邊框和背景。
語法
設置emptyCells 屬性:
Object.style.emptyCells="show|hide|inherit"
返回emptyCells 屬性:
Object.style.emptyCells
值 | 描述 |
---|---|
show | 显示空单元格的边框和背景,即在空单元格周围绘制边框。 |
hide | 隐藏空单元格的边框和背景,即不在空单元格周围绘制边框。 |
inherit | emptyCells 属性的值从父元素继承。 |
瀏覽器支持
所有主要瀏覽器都支持emptyCells 屬性。
注意:不同瀏覽器中的默認值不同。在IE、Chrome 和Safari 瀏覽器中,默認值是"show",而在Firefox 和Opera 瀏覽器中,默認值是"hide"。
注意: IE7及更早的版本不支持emptyCells屬性。IE8 只有規定了!DOCTYPE 才支持emptyCells 屬性。 IE9 支持emptyCells 屬性。
實例
實例
改變空單元格的顯示方式:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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>
嘗試一下»
Style對象