I am struggling to figure out how to embed a table inside a button in order to display the table when the button is clicked and hide it when clicked again. Below is the code I have been working with:
function toggleTable(){
document.getElementById("displaytable").style.display = (document.getElementById("displaytable").style.display == "none") ? "block" : "none";
}
<input type="button" value="Show/Hide Table" onclick='toggleTable();'>
<div id="displaytable" style="display: none">
<table id="displaytable" style="width: 100%" cellpadding="1" cellspacing="0" border="3">
<tr align="center">
<td class="lbl">Header 1</td>
<td class="lbl">Header 2</td>
<td class="lbl">Header 3</td>
</tr>
<tr>
<td align="center">Cell 1</td>
<td align="center">Cell 2</td>
<td align="center">Cell 3</td>
</tr>
<tr>
<td align="center">Cell 4</td>
<td align="center">Cell 5</td>
<td align="center">Cell 6</td>
</tr>
</table>
</div>