Tabella createTFoot() Metodo
Esempio
Crea un elemento <tfoot> (e inserisci un elemento <tr> e <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>";
Definizione e utilizzo
Il metodo createTFoot() crea un elemento <tfoot> vuoto e lo aggiunge alla tabella.
Nota: se nella tabella esiste già un elemento <tfoot>, il metodo createTFoot() restituisce quello esistente e non ne crea uno nuovo.
Nota: l'elemento <tfoot> deve avere uno o più tag <tr> all'interno.
Suggerimento: per rimuovere l'elemento <tfoot> da una tabella, utilizzare il metodo deleteTFoot() .
Supporto browser
Method | |||||
---|---|---|---|---|---|
createTFoot() | Yes | Yes | Yes | Yes | Yes |
Sintassi
tableObject.createTFoot()
Parametri
Nessuno |
Dettagli tecnici
Valore di ritorno: | L'elemento <tfoot> appena creato (o esistente). |
---|
Altri esempi
Esempio
Crea ed elimina un elemento <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();
}
Pagine correlate
Riferimento HTML: tag HTML <tfoot>
❮ Oggetto tabella