Javascript DOM HTML Table tFoot Property

Introduction

Get the innerHTML of <tfoot>:

Click the button to return the innerHTML of the tfoot element.

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
table, td {
  border: 1px solid black;
}
</style>/*from   ww  w . j  a  v a2s.com*/
</head>
<body>
<p id="demo"></p>
<table id="myTable">
   <thead>
     <tr>
       <th>Month</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("demo").innerHTML =document.getElementById("myTable").tFoot.innerHTML;
}
</script>

</body>
</html>

The tFoot property returns a reference to the <tfoot> element of a table.

The <tfoot> element is used to group the footer content in an HTML table.

The tHead property returns a reference to the <thead> element of a table.




PreviousNext

Related