Home › Forums › JavaScript › JQuery: Hide a div if anything except the div and its content is clicked › Reply To: JQuery: Hide a div if anything except the div and its content is clicked
April 28, 2015 at 7:54 pm
#201295
Participant
I found this useful…
jQuery(document).click(function(event){
// Check if clicked outside .target-div
if (!(jQuery(event.target).closest(".target-div").length)) {
// Hide .target-div
jQuery(".target-div").hide();
}
});