I am trying to create a login form which appear and disappear when users click the login button. The code below ensure that the form does not show at start and only display form when user clicks it. However, the form is not disappearing despite clicking the button for the second time. I also included the jquery string below. Am I missing something or is it because the jquery code is outdated?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
$(document).ready(function() {
const arrow = $(".arrow-up");
const form = $(".login-form");
const status = false;
$("#login").click(function(event) {
event.preventDefault();
if (status == false) {
arrow.fadeIn();
form.fadeIn();
status == true;
} else {
arrow.fadeOut();
form.fadeOut();
status = false;
}
})
})
.arrow-up {
width: 0;
height: 0;
position: absolute;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-bottom: 20px solid #e86b00;
right: 750px;
bottom: 10px;
display: none;
}
.login-form {
position: absolute;
width: 300px;
height: auto;
background: #e86b00;
top: 20px;
right: -150px;
border-radius: 3px;
border-bottom: 5px solid gray;
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<li><a href="#" id="login">LogIn</a></li>
<div class="arrow-up">
<div class="login-form">
<form>
<div>
<label style="color:black">Username:</label>
<input type="text" placeholder="Username" id="usernm" autocomplete="new-password" required/>
</div>
<div>
<label style="color:black">Password:</label>
<input type="password" placeholder="Password" id="passw" autocomplete="new-password" required/>
</div>
<div>
<input type="submit" />
</div>
<div>
<a href="#">Lost Your Password</a>
</div>
</form>
</div>
</div>