I implemented a functionality of JS show Modal() and I want to close it when someone click outside the popup means on document.
I implemented a functionality of JS show Modal() and I want to close it when someone click outside the popup means on document.
2
Answers
Below is a work demo, you can refer to it:
result:
You can wrap the dialog-content in a div with
padding: 0
. This way you can check forevent.target
of the click-event, which references the dialog in case of backdrop and any other element within the div in case of the actual modal.