DEV Community

can
can

Posted on

Answer: Detect click outside div using javascript

It depends on the individual use case but it sounds like in this example there are likely to be other nested elements inside the main div e.g. more divs, lists etc. Using Node.contains would be a useful way to check whether the target element is within the div that is…

Top comments (0)