Click outside element to close (modals / popups / menus)

PHOTO EMBED

Fri Oct 15 2021 21:31:56 GMT+0000 (Coordinated Universal Time)

Saved by @markf_raindrop #jquery #javascript

$(document).on('click', function(e) {
  // Elements you don't want to remove the class name with...
  if($(e.target).is('.element-name, .element-open-toggle') === false) {
    // If anything outside of those is clicked, remove the active class to hide the popup.
    $('body').removeClass('class-name');
  }
})
content_copyCOPY