I'm doing a "start session" button that when clicked, a modal appears below it to put your data and be able to login. The issue is that I do not have much experience and I do not know how to close it. I'm doing it with HTML CSS JS and NodeJS. The modal code is this:
<div id="modal">
<div id="modalcontainer">
<h3>Iniciar sesión</h3>
<input type="text" placeholder="Usuario" id="modaluser">
<input type="password" placeholder="Contraseña" id="modalpassword">
<button type="submit">Ingresá</button>
</div>
with css I made the modal id occupy the whole screen but it is transparent and the modal container is a lot smaller and is in a part of the screen. What I want is that when I touch the modal that occupies all or another part that is not the modalcontainer, the modalcontainer will close. How can I do?
With JS to open the modal I did this:
var btnlogin=document.getElementById("btnlogin");
var modal=document.getElementById("modal");
function modaldisplay(){
modal.style.display="inline";
}
To close it as I had thought, try this but it did not work:
modal.onclick(function modalclose(){
modal.style.display="none";
})
Thank you very much!