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>IT研修(xuhuhu.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>IT研修(xuhuhu.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>
