<!DOCTYPE html>
<html>
<head>
<style>
table {
margin: 12px;
}
table, td, th {
border-collapse: collapse;
border: 1px solid black;
}
td, th {
padding: 12px;
transition: padding 0.5s ease-out;
}
thead.collapsed th {
padding-top: 6px;
padding-bottom: 6px;
transition: padding 0.5s ease-out;
}
thead.collapsible {
cursor: pointer;
}
.invisible th, .invisible td {
display: none;
}
</style>
</head>
<body>
<table>
<thead id="table-collapse-toggle-16" class="collapsible" onclick = "collapse_table('16')">
<th>Default: open</th>
<th>2</th>
<th>3</th>
</thead>
<tbody id="collapsible-table-16">
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</tbody>
</table>
<table>
<thead id="table-collapse-toggle-26" class="collapsible collapsed" onclick="collapse_table('26')">
<th>Default: Collapsed</th>
<th>2</th>
<th>3</th>
</thead>
<tbody id="collapsible-table-26" class="invisible">
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</tbody>
</table>
<table>
<thead id="table-collapse-toggle-0" class="collapsible" onclick ="collapse_table('0')">
<tr><th> Click Me! (Default shown) </th></tr>
</thead>
<tbody id="collapsible-table-0">
<tr><td> Hi, there! </td></tr>
</tbody>
</table>
<table>
<thead id="table-collapse-toggle-1" class="collapsible collapsed" onclick ="collapse_table('1')">
<tr><th> Click Me! (Default hidden) </th></tr>
</thead>
<tbody id="collapsible-table-1" class="invisible">
<tr><td> Hi, there! </td></tr>
</tbody>
</table>
<script>
function collapse_table(n) {
var head = document.getElementById("table-collapse-toggle-" + n);
head.classList.toggle("collapsed");
var content = document.getElementById("collapsible-table-" + n);
content.classList.toggle("invisible");
}
</script>
</body>
</html>