td/th axis 属性
td/th 对象
定义和用法
axis 属性可设置或返回一个由逗号分隔的列表,其中包含了一组类型(有关联的单元格)的名称。
语法
设置 axis 属性:
tdObject.axis = "text" 或 thObject.axis = "text"
返回 axis 属性:
tdObject.axis或者 thObject.axis
提示:axis属性没有默认值。
浏览器支持
![]()
![]()
![]()
![]()
![]()
所有主流浏览器都支持 axis 属性。
实例
下面的例子可返回单元格的 axis:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>蜜蜂教程(mifengjc.com)</title>
<script>
function displayResult() {
var x = document.getElementById("myTable");
var th = x.getElementsByTagName("th");
for (var i = 0; i < th.length; i++) {
alert("The " + (i + 1) + ". column axis is: " + th[i].axis);
}
}
</script>
</head>
<body>
<table border="1" id="myTable">
<tr>
<th axis="car">名称</th>
<th axis="country">国家</th>
</tr>
<tr>
<td>BMW</td>
<td>Germany</td>
</tr>
<tr>
<td>Volvo</td>
<td>Sweden</td>
</tr>
<tr>
<td>Saab</td>
<td>Sweden</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">获取Axis</button>
</body>
</html>
td/th 对象