Método createTFoot() da tabela
Exemplo
Crie um elemento <tfoot> (e insira um elemento <tr> e <td> nele):
// 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>";
Definição e uso
O método createTFoot() cria um elemento <tfoot> vazio e o adiciona à tabela.
Nota: Se um elemento <tfoot> já existir na tabela, o método createTFoot() retornará o existente e não criará um novo.
Nota: O elemento <tfoot> deve ter uma ou mais tags <tr> dentro.
Dica: Para remover o elemento <tfoot> de uma tabela, use o método deleteTFoot() .
Suporte ao navegador
Method | |||||
---|---|---|---|---|---|
createTFoot() | Yes | Yes | Yes | Yes | Yes |
Sintaxe
tableObject.createTFoot()
Parâmetros
Nenhum |
Detalhes técnicos
Valor de retorno: | O elemento <tfoot> recém-criado (ou existente) |
---|
Mais exemplos
Exemplo
Crie e exclua um 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();
}
Páginas relacionadas
Referência HTML: tag HTML <tfoot>
❮ Objeto de Tabela