Javascript examples for DOM HTML Element:TableHeader
TableHeader headers Property - Display cell headers of second row:
<!DOCTYPE html> <html> <head> <style> table, th { border: 1px solid black; } </style>//from www. j a v a 2 s .co m </head> <body> <table id="myTable"> <tr> <th id="name" colspan="3">Name</th> </tr> <tr> <th headers="fname">First name</th> <th headers="mname">Middle name</th> <th headers="lname">Last name</th> </tr> </table> <br> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var table = document.getElementById("myTable"); var txt = ""; var i; for (i = 0; i < table.rows[1].cells.length; i++) { txt = txt + table.rows[1].cells[i].headers + "<br>"; } document.getElementById("demo").innerHTML = txt; } </script> </body> </html>