You are here: Reference > JavaScript > client-side > HTML DOM > methods > createTFoot (table)

createTFoot method (table)

Browser support:
Creates an empty tfoot element and adds it to the current table.
If a tfoot already exists on the current table, the createTFoot method returns it and does not create a new one.
Another way to create a tfoot element is to use the createElement method. To remove the footer from a table, use the deleteTFoot method.

Syntax:

object.createTFoot ( );
You can find the related objects in the Supported by objects section below.

Return value:

Returns the newly created or the existing tfoot element.

Example HTML code 1:

This example illustrates the use of the createTFoot method:
<head>
    <script type="text/javascript">
        function CreateFooter () {
            var table = document.getElementById ("myTable");
            if (!table.tFoot) {
                var footer = table.createTFoot ();
                var row = footer.insertRow (0);
                var cell = row.insertCell (0);
                cell.innerHTML = "<b>Footer for the table.</b>";
            }
        }
    </script>
</head>
<body>
    <table id="myTable" border="1px">
        <tbody>
            <tr>
                <td>This text is inside the table.</td>
            </tr>
        </tbody>
    </table>
    <br /><br />
    <button onclick="CreateFooter ();">Create a footer for the table!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content