$(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'); } })
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter