<!DOCTYPE html>
<html>
<body>
<h1>Create a thead Element</h1>
<table id="myTable">
<tr>
<td>Cell 1</td>
</tr>
<tr>
<td>Cell 2</td>
</tr>
<tr>
<td>Cell 2</td>
</tr>
</table>
<p>Click "Try it" to create a thead element.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
const x = document.createElement("thead");
const y = document.createElement("tr");
const z = document.createElement("td");
z.innerHTML = "Header"
y.appendChild(z);
x.appendChild(y);
document.getElementById("myTable").appendChild(x);
}
</script>
</body>
</html>