TableHeader headers Property - Change the value of the headers attribute of a <th> element with id "myTh": - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:TableHeader

Description

TableHeader headers Property - Change the value of the headers attribute of a <th> element with id "myTh":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
table, th {
    border: 1px solid black;
}
</style>/*from   w w w  .j  ava 2s.  co m*/
</head>
<body>

<table id="myTable">
  <tr>
    <th id="name" colspan="3">Name</th>
  </tr>
  <tr>
    <th id="myTh" 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() {
    document.getElementById("myTh").headers = "newValue";
    document.getElementById("demo").innerHTML = "changed";
}
</script>

</body>
</html>

Related Tutorials