<!DOCTYPE html>
<html>
<head>
<style>
table, th {
    border: 1px solid black;
}

</style>
</head>
<body>

<p>Click the button to return the value of the headers attribute of th with id "myTh".</p>

<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()">Try it</button>

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

<script>
function myFunction() {
    var x = document.getElementById("myTh").headers;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>