Get TableHeader Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:TableHeader


The TableHeader object represents an HTML <th> element.

You can access a <th> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
table, th, td {
    border: 1px solid black;
</style>//  w  w  w .  j a va2 s . c om

   <th id="myTh">Name</th>

<button onclick="myFunction()">change the text of the TH element</button>

<p id="demo"></p>

function myFunction() {
    var x = document.getElementById("myTh");
    x.innerHTML = "New Table Header";


Related Tutorials