Hide-1 (Table/Text/Content): 1-Section
Hide (Table/Text/Content): 1-Section
( 2-Section Link )
( Multi-Section Link )
Code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Toggle Data Table</title>
</head>
<body>
<h2>Data Table</h2>
<div style="background: lightgrey; padding: 0px;">
<button id="Stock-toggle-Button" onclick="StocktoggleTable()" style="width: 100%; text-align: left;">Stock (Show Table)</button>
<table border="1" id="Stock-data-Table" style="display: none;">
<thead>
<tr>
<th>Item</th>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>John Doe</td>
<td>28</td>
<td>New York</td>
</tr>
<tr>
<td>2</td>
<td>Jane Smith</td>
<td>34</td>
<td>Los Angeles</td>
</tr>
</tbody>
</table>
</div><br>
<script>
function StocktoggleTable() {
const table = document.getElementById("Stock-data-Table");
const toggleButton = document.getElementById("Stock-toggle-Button");
if (table.style.display === "none") {
table.style.display = "table";
toggleButton.textContent = "Stock (Hide Table)";
} else {
table.style.display = "none";
toggleButton.textContent = "Stock (Show Table)";
}
}
</script>
</body>
</html>
Data Table
# | Name | Age | City |
---|---|---|---|
1 | John Doe | 28 | New York |
2 | Jane Smith | 34 | Los Angeles |
Comments
Post a Comment