Javascript DOM HTML Table deleteTFoot() Method

Introduction

Remove a <tfoot> element from a table:

document.getElementById("myTable").deleteTFoot();

Click the button to remove the tfoot element from the table.

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>/*w  w w. j av  a2  s. co m*/
</head>
<body>
<table id="myTable">
  <thead>
    <tr><th>Item</th><th>Savings</th></tr>
  </thead>
  <tfoot><tr><td>Sum</td><td>$180</td></tr>
  </tfoot>
  <tbody>
    <tr><td>January</td><td>$100</td></tr>
    <tr><td>February</td><td>$180</td></tr>
  </tbody>
</table>
<br>

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

<script>
function myFunction() {
  document.getElementById("myTable").deleteTFoot();
}
</script>

</body>
</html>

The deleteTFoot() method removes the <tfoot> element from the table.




PreviousNext

Related