HTML DOM Table rules 屬性
定義和用法
rules 屬性可設置或返回表格的內部邊線。
語法
設置rules 屬性:
tableObject.rules="none|groups|rows|cols|all"
返回rules 屬性:
tableObject.rules
值 | 描述 |
---|---|
none | 没有内部边界 |
groups | 显示行组和列组之间的内部边界 |
rows | 显示内部行之间的边界 |
cols | 显示的列之间内部边界 |
all | 显示行和列之间的内边界 |
瀏覽器支持
所有主要瀏覽器都支持rules 屬性
注意: IE9可以正確顯示此屬性。早期版本的IE 除了內部四個邊界外,還會添加四個外邊界。
注意: Chrome和Safari可以正確顯示此屬性:除了內邊框外還會影響外邊框。
實例
實例
下面的例子設置了表格的兩種不同的內部邊線:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function rows(){
document.getElementById('myTable').rules="rows";
}
function cols(){
document.getElementById('myTable').rules="cols";
}
</script>
</head>
<body>
<table id="myTable">
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<br>
<button type="button" onclick="rows()">只显示行边界</button>
<button type="button" onclick="cols()">只显示列边界</button>
<p><b>注意:</b> rules属性在Internet Explorer 9之前版本不能正常显示。</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function rows(){
document.getElementById('myTable').rules="rows";
}
function cols(){
document.getElementById('myTable').rules="cols";
}
</script>
</head>
<body>
<table id="myTable">
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<br>
<button type="button" onclick="rows()">只显示行边界</button>
<button type="button" onclick="cols()">只显示列边界</button>
<p><b>注意:</b> rules属性在Internet Explorer 9之前版本不能正常显示。</p>
</body>
</html>
嘗試一下»
Table對象