Table createTFoot()Method
Table Object
Definition and Usage
The createTFoot() method is used to get or create a <tfoot> element in a table.
Note:If the tfoot element already exists in the table, the createTFoot() method returns the existing value and will not create a new <tfoot> element.
Tip:To remove the tfoot element from the table, usedeleteTFoot()method.
Syntax
tableObject.createTFoot()
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the createTFoot() method
Examples
Examples
Create and delete a tfoot element:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function createTFoot(){
var x=document.getElementById("myTable");
if (!x.tFoot){
var footer=x.createTFoot();
var row=footer.insertRow(0);
var cell=row.insertCell(0);
cell.innerHTML="<b>This is a table footer</b>";
}
}
function deleteTFoot(){
document.getElementById("myTable").deleteTFoot();
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<br>
<button type="button" onclick="createTFoot()">Create Table Footer</button>
<button type="button" onclick="deleteTFoot()">Delete Table Footer</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function createTFoot(){
var x=document.getElementById("myTable");
if (!x.tFoot){
var footer=x.createTFoot();
var row=footer.insertRow(0);
var cell=row.insertCell(0);
cell.innerHTML="<b>This is a table footer</b>";
}
}
function deleteTFoot(){
document.getElementById("myTable").deleteTFoot();
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<br>
<button type="button" onclick="createTFoot()">Create Table Footer</button>
<button type="button" onclick="deleteTFoot()">Delete Table Footer</button>
</body>
</html>
Try it Yourself »
Table Object Other Extensions