`i want my code to hide and show a div on click...but now it is just hiding for a milisecond and show again...so i don't know what is the problem can someone help me...thanks in advance
to hide when i click toggle and hide when i click again here is my code
const targetDiv = document.getElementById("insign");
const btn = document.getElementById("toggle");
btn.onclick = function() {
if (targetDiv.style.display !== "none") {
targetDiv.style.display = "none";
} else {
targetDiv.style.display = "block";
}
};
.insign {
position: absolute;
margin-top: 20%;
color: white;
background-color: rgba(1, 1, 1, 0.7);
border-radius: 9px;
border: 1px solid gold;
padding: 2% 1%;
width: 25%;
align-items: center;
justify-content: center;
text-align: center;
animation: form 0.9s ease-out;
}
<form>
<button class="signin" id="toggle">Sign In</button>
<div class="insign" id="insign">
<div class="content_in">
<h1>Log In</h1>
</div>
<div class="content_in">
<p>Username</p>
<input type="text" placeholder="enter username"></div>
<div class="content_in">
<p>Password</p>
<input type="password" placeholder="enter password"></div>
<div class="content_in"><a>forgot password?</a><button id="sgnin">Log In</button></div>
</div>
<script>
</script>
</form>