A
A
AlexRayn2020-05-19 13:12:16
React
AlexRayn, 2020-05-19 13:12:16

How to close the modal when clicking past?

https://codepen.io/loozmax/pen/ExVRaew?editors=0110

It is necessary that when you click past the form, it closes. How to implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hzzzzl, 2020-05-19
@AlexRayn

put div position:fixed under the modal to full screen (at the same time you can set a translucent color for it), catch a click on this div and then remove the modal

I
Igor, 2020-05-19
@loonny

You can catch clicks on the parent element and check the target property

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question