This is a simple modal overlay made with pure js, css, and html.
This is a simple modal overlay made with pure js, css, and html.
For further actions, you may consider blocking this person and/or reporting abuse
Marcus Kohlberg -
Balraj Singh -
Khalif AL Mahmud -
Mitchell -
Top comments (2)
The modal is great, but the code isn't really.
You're using a
modal
and abackdrop
global variable, which firstly is bad practice, but also means there cannot be stacked modals on top of each other. You should instead keep the elements inside the context of the function that creates them.Furthermore, you'd usually not want any complex HTML creation in JavaScript. What you'd ideally want is an HTML template that is shown when the button is clicked. Additionally you can customize the content of the modal using this method, without having to create the modal from scratch in JavaScript.
Thank you very much Oskar :) Very useful.