- Julian Lin You could do button.parentElement, but if the button were to ever more or be nested inside of something, that wouldn't work that well. Not the answer you're looking for? Connect and share knowledge within a single location that is structured and easy to search. Now let's get to the solution on how to close a popup when clicked outside the element. I talked about this. Making statements based on opinion; back them up with references or personal experience. Short story about swapping bodies as a job; the person who hires the main character misuses his body, Image of minimal degree representation of quasisimple group unique up to conjugacy. How are you checking to make sure the target of the event is not the div in question? If you use above directive to close popUp window, remember first to add event.stopPropagation() to button click event handler which open popUp. When I click on the dropdown menu, go to an URL address. 2. The overlay package provides a way to open floating panels on the screen. What does 'They're at four. How can I validate an email address in JavaScript? Not the answer you're looking for? Why does Acts not mention the deaths of Peter and Paul? I read them but not possible to reproduce them with my code. If the null hypothesis is never really true, is there a point to using a statistical test without a priori power analysis? I tried the followings that do not works for me: or But when i click outside the opened dialog the main window reatcs. How to close Bootstrap open collapse navbar clicking outside of navbar elements [Best method] Kiran Acharya / January 9, 2021 / Bootstrap, CSS You might be trying to relocate the navbar to the right or left side of the layout. Where does the version of Hamapil that is different from the Gemara come from? To learn more, see our tips on writing great answers. I check it and it works well (i only copy clickOutside.directive.ts to my project). For left and right sidebar or navbars closing them by clicking outside is a good functionality. Are there any canonical examples of the Prime Directive being broken that aren't shown on screen? Could you possibly explain further?