TableHeaderヘッダープロパティ
例
IDが「myTh」の<th>要素のheaders属性の値を返します。
var x = document.getElementById("myTh").headers;
定義と使用法
headersプロパティは、headers属性の値を設定または返します。
headers属性は、現在のデータセルのヘッダー情報を含むヘッダーセルのリストを指定します。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
headers | Yes | Yes | Yes | Yes | Yes |
構文
ヘッダープロパティを返します。
tableheaderObject.headers
ヘッダープロパティを設定します。
tableheaderObject.headers = header_ids
プロパティ値
Value | Description |
---|---|
header_ids | Specifies a space-separated list of id's to one or more header cells the table cell is related to |
技術的な詳細
戻り値: | ヘッダーセル識別子のスペースで区切られたリストを含む文字列 |
---|
その他の例
例
2行目のセルヘッダーを表示します。
var table = document.getElementById("myTable");
var txt = "";
var i;
for (i = 0; i < table.rows[1].cells.length; i++) {
txt = txt + table.rows[1].cells[i].headers + "<br>";
}
例
IDが「myTh」の<th>要素のheaders属性の値を変更します。
document.getElementById("myTh").headers = "newValue";
関連ページ
HTML参照:HTML <th>ヘッダー属性
❮TableHeaderオブジェクト