Table createTFoot() method

Definition and Usage

createTFoot() The method creates an empty <tfoot> Element and add it to the table.

Note:If the <tfoot> element already exists in the table, then createTFoot() The method returns the existing element without creating a new one.

Note:The <tfoot> element must contain one or more <tr> tags inside.

Tip:To remove the <tfoot> element from the table, use deleteTFoot() method.

See also:

HTML Reference Manual:HTML <tfoot> Tag

Example

Example 1

Create <tfoot> element (and insert <tr> and <td> elements inside):

// Find the <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 bold text to the new cell:
cell.innerHTML = "<b>This is a table footer</b>";

Subukan Mo Rin

Example 2

Create and delete <tfoot> elements:

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();
}

Subukan Mo Rin

Syntax

tableObject.createTFoot()

Parametro

Wala.

Detalye ng Teknolohiya

Bilang na ibabalik: Bagong nilikha (o umiiral na)<tfoot> Element.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support