Tabla método createTFoot()
Ejemplo
Cree un elemento <tfoot> (e inserte un elemento <tr> y <td> en él):
// 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>";
Definición y uso
El método createTFoot() crea un elemento <tfoot> vacío y lo agrega a la tabla.
Nota: si ya existe un elemento <tfoot> en la tabla, el método createTFoot() devuelve el existente y no crea uno nuevo.
Nota: El elemento <tfoot> debe tener una o más etiquetas <tr> dentro.
Sugerencia: para eliminar el elemento <tfoot> de una tabla, utilice el método deleteTFoot() .
Compatibilidad con navegador
Method | |||||
---|---|---|---|---|---|
createTFoot() | Yes | Yes | Yes | Yes | Yes |
Sintaxis
tableObject.createTFoot()
Parámetros
Ninguna |
Detalles técnicos
Valor devuelto: | El elemento <tfoot> recién creado (o existente) |
---|
Más ejemplos
Ejemplo
Crear y eliminar 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();
}
páginas relacionadas
Referencia HTML: etiqueta HTML <tfoot>
❮ Objeto de tabla