Javascript examples for DOM HTML Element:TableHeader
You can create a <th> element by using the document.createElement() method:
<!DOCTYPE html> <html> <head> <style> table, th { border: 1px solid black; } </style>/*from w w w .jav a2 s .c o m*/ </head> <body> <table id="myTable"> <tr id="myTr"> </tr> </table> <button onclick="myFunction()">create a TH element</button> <script> function myFunction() { var x = document.createElement("TH"); var t = document.createTextNode("table header cell"); x.appendChild(t); document.getElementById("myTr").appendChild(x); } </script> </body> </html>