テーブルcreateTFoot()メソッド
例
<tfoot>要素を作成します(そしてそれに<tr>要素と<td>要素を挿入します):
// Find a <table> element with id="myTable":
var table = document.getElementById("myTable");
// Create an empty <tfoot> element and add it to the table:
var footer = table.createTFoot();
// Create an empty <tr> element and add it to the first position of <tfoot>:
var row = footer.insertRow(0);
// Insert a new cell (<td>) at the first position of the "new" <tr> element:
var cell = row.insertCell(0);
// Add some bold text in the new cell:
cell.innerHTML = "<b>This is a table footer</b>";
定義と使用法
createTFoot()メソッドは、空の<tfoot>要素を作成し、それをテーブルに追加します。
注: <tfoot>要素がテーブルにすでに存在する場合、createTFoot()メソッドは既存の要素を返し、新しい要素を作成しません。
注: <tfoot>要素には、1つ以上の<tr>タグが含まれている必要があります。
ヒント:テーブルから<tfoot>要素を削除するには、 deleteTFoot()メソッドを使用します。
ブラウザのサポート
Method | |||||
---|---|---|---|---|---|
createTFoot() | Yes | Yes | Yes | Yes | Yes |
構文
tableObject.createTFoot()
パラメーター
なし |
技術的な詳細
戻り値: | 新しく作成された(または既存の)<tfoot>要素 |
---|
その他の例
例
<tfoot>要素を作成および削除します。
function myCreateFunction() {
var table = document.getElementById("myTable");
var footer = table.createTFoot();
var row = footer.insertRow(0);
var cell = row.insertCell(0);
cell.innerHTML = "<b>This is a table footer</b>";
}
function myDeleteFunction() {
document.getElementById("myTable").deleteTFoot();
}
関連ページ
HTMLリファレンス:HTML <tfoot>タグ
❮テーブルオブジェクト