td/th abbrプロパティ
td/th オブジェクト
定義と使い方
abbr プロパティは、表セル内のコンテンツの省略バージョン(音声や点字などの非視覚メディア向け)を設定または返します。
このプロパティが設定されている場合、ユーザーは abbr プロパティの値(セル内のコンテンツではなく)のみを聞くことができます。
構文
abbr プロパティを設定する:
tdObject.abbr="text"
または
thObject.abbr="text"
または
thObject.abbr="text"
abbr プロパティを返す:
tdObject.abbr
または
thObject.abbr
または
thObject.abbr
ヒント:abbr プロパティにはデフォルト値がありません。
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザが abbr プロパティをサポートしています。
例
例
次の例は、最初のセルの abbr を表示します:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
var table=document.getElementById("myTable");
alert(table.rows[0].cells[0].abbr);
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td abbr="def">名前を短く保つための省略形。ブラウザはこれらを繰り返し表示する場合があります。</td>
<td>セルデータ</td>
</tr>
<tr>
<td>セルデータ</td>
<td>セルデータ</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">最初のセルの省略形を取得</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
var table=document.getElementById("myTable");
alert(table.rows[0].cells[0].abbr);
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td abbr="def">名前を短く保つための省略形。ブラウザはこれらを繰り返し表示する場合があります。</td>
<td>セルデータ</td>
</tr>
<tr>
<td>セルデータ</td>
<td>セルデータ</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">最初のセルの省略形を取得</button>
</body>
</html>
試してみる »
td/th オブジェクト その他の拡張