Create a TableHeader Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:TableHeader


You can create a <th> element by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
table, th {
    border: 1px solid black;
</style>/*from  w w  w  .jav  a2  s .c o  m*/

<table id="myTable">
  <tr id="myTr">

<button onclick="myFunction()">create a TH element</button>

function myFunction() {
    var x = document.createElement("TH");
    var t = document.createTextNode("table header cell");


Related Tutorials