$(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'); } })