Prevent onClick event by clicking on a child div

前端 未结 2 650
醉酒成梦
醉酒成梦 2021-01-14 17:27

I\'m trying to create a modal in React JS

I have one outter div which is the whole body and I have I inner div. I want to apply the function to close the modal if it

2条回答
  •  生来不讨喜
    2021-01-14 18:16

    You could use JS Event.stopPropagation to prevent event from bubbling to the parent if inner element is clicked.

提交回复
热议问题