Get the innerHTML of <thead>:
Click the button to return the innerHTML of the thead element.
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style>//from w ww . j a v a2s .c o m </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>$810</td> </tr> </tbody> </table> <br> <button onclick="myFunction()">Test</button> <script> function myFunction() { document.getElementById("demo").innerHTML = document.getElementById("myTable").tHead.innerHTML; } </script> </body> </html>
The tHead property returns a reference to the <thead> element of a table.
The <thead> element groups the header content in an HTML table.
The tFoot property returns a reference to the <tfoot> element of a table.
The tFoot property returns null if it is not defined.