<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<table id="myTable">
</table>
<p>Click the button to create a TBODY element (and a TR and a TD).</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x = document.createElement("TBODY");
var y = document.createElement("TR");
var z = document.createElement("TD");
z.innerHTML = "A table cell inside a tr inside a tbody inside a table!"
y.appendChild(z);
x.appendChild(y);
document.getElementById("myTable").appendChild(x);
}
</script>
</body>
</html>