td/th axis属性
td/th オブジェクト
定義と使い方
axis 属性は、関連するセルを持つグループのタイプ名を含むカンマ区切りのリストを設定または返します。
構文
axis 属性を設定する:
tdObject.axis="text"
または
thObject.axis="text"
または
thObject.axis="text"
axis 属性を返す:
tdObject.axis
または
thObject.axis
または
thObject.axis
ヒント:axis 属性にはデフォルト値がありません。
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザは axis 属性をサポートしています。
例
例
次の例は、セルの axis を返します。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.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>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.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 オブジェクト
その他の拡張