I have a modal pop-up windows on an HTML page, and after they're opened, it doesnt close by clicking outside of the modal with this code:
Opening working perfectly but it doesnt close. I will be happy if somebody let me fix this issue/
Thank you so much
var BtnLogin = document.getElementById("login");
var LoginScreen = document.getElementById('login-js');
BtnLogin.onclick = function() {
LoginScreen.style.display = "block";
}
window.onclick = function(event) {
if (event.target == LoginScreen) {
LoginScreen.style.display = "none";
}
}
.login-member {
background-color: #ffffff;
position: absolute;
right: 0px;
top: 38px;
width: 280px;
height: 200px;
display: none;
}
<ul class="navbar-account">
<li class="login" id="login">LOGIN
<div class="login-member" id="login-js">
<form class="login-form" action="login.php" method="post">
<div class="email">
<input id="email" type="text" placeholder="Email Adress" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Email Adress'">
<span> <i class="fas fa-envelope icon-position"></i></span>
</div>
<div class="password">
<input id="password" type="password" placeholder="Password" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Password'">
<span><i class="fas fa-lock icon-position"></i></span>
</div>
<button type="submit">LOGIN</button>
</form>
</div>
</li>
</ul>