Close div with click outside (parent) [duplicate]
问题 This question already has answers here : How do I detect a click outside an element? (84 answers) Closed 2 years ago . This is not a new problem on stackoverflow, but I've tried everything without success. I have a "popup" created with two divs. The parent ist the background and the child is the popup content. I want to hide the popup when the user clicks on the background (the parent). It sounds extremly easy also for me but I can't achieve that. This is my code and what I tried (it works