Table createTFoot() Method - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Table


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

If a <tfoot> element already exists on the table, the createTFoot() method returns the existing one.



Return Value:

The newly created or an existing <tfoot> element

The following code shows how to Create a <tfoot> element with <tr> and <td> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
table, td {
    border: 1px solid black;
</style>//from   ww w .  j a v  a 2s  . com

<table id="myTable">
    <td>cell 1</td>
    <td>cell 2</td>
    <td>cell 3</td>
    <td>cell 4</td>

<button onclick="myFunction()">Test</button>

function myFunction() {
    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>";


Related Tutorials