I am trying to make a hidden table. When you click a button, it should appear on the page and then when you click on that again, it should disappear. The problem is, this code is not working:
That is the function of JS
function showtable1() {
var x = document.getElementById("table");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
This one is the HTML codes:
<body>
<video autoplay loop muted id="backgroundv1">
<source src="fp.mp4" type="video/mp4">
</video>
<div class="menü1">
<button class="button" onclick="showtable1()">Project 1</button>
<button class="button">Project 2</button>
<button class="button">Project 3</button>
<button class="button">Project 4</button>
<button class="button">Project 5</button>
</div>
<table class="table1"><td></td> <td></td> </table>
</body>
also if you need CSS code:
.table1 {
width: 64%;
height: 50%;
border: 2px solid red;
border-radius: 12px;
margin-left: auto;
margin-right: auto;
transform: translate(0);
}
document.getElementsByClassName("table1");var x = document.getElementById("table");byvar x = document.querySelector(".table1");. Since the table have noidattribute, but it have a particular class.