Tabulka createTFoot() Metoda
Příklad
Vytvořte prvek <tfoot> (a vložte do něj prvky <tr> a <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>";
Definice a použití
Metoda createTFoot() vytvoří prázdný prvek <tfoot> a přidá jej do tabulky.
Poznámka: Pokud prvek <tfoot> již v tabulce existuje, metoda createTFoot() vrátí existující prvek a nevytvoří nový.
Poznámka: Element <tfoot> musí mít uvnitř jeden nebo více tagů <tr>.
Tip: Chcete-li odstranit prvek <tfoot> z tabulky, použijte metodu deleteTFoot() .
Podpora prohlížeče
Method | |||||
---|---|---|---|---|---|
createTFoot() | Yes | Yes | Yes | Yes | Yes |
Syntax
tableObject.createTFoot()
Parametry
Žádný |
Technické údaje
Návratová hodnota: | Nově vytvořený (nebo existující) prvek <tfoot> |
---|
Další příklady
Příklad
Vytvoření a odstranění prvku <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();
}
Související stránky
HTML reference: HTML tag <tfoot>
❮ Objekt tabulky