Hiding a Dialog Box on Outside Click


/ Published in: jQuery
Save to your folder(s)

This is essentially how to detect an outside click for a dialog box on a website, using HTML/CSS/Javascript/JQuery.

Essentially you need to understand event propagation how it works throughout the DOM with JQuery, to make this as simple as possible. Add a listener to the html or body element that detects a click, hide the box when it receives that event. Otherwise, stop the propagation of the event when the container receives it (the event).

If you have any question, or want a further explanation, don't hesitate to get in contact with me.

Cheers!

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.