salahaldain-abduljalil's avatar

toggle content with clicking outside

Excuse me guys if I am using like this function function toggleselver(modalId) {
const modal = document.getElementById(modalId);
if (modal) {
modal.classList.toggle('hidden');

}  

} to toggle modal showing and hide I need also when I clicking outside the form will be hidden just if its visible How to customize that.

..Best Regards.

1 like
3 replies
vincent15000's avatar

A modal is usually displayed with a blurred background on the whole page.

You can add an event listener on this background and if you click on it, you close the modal.

Please or to participate in this conversation.