jQuery: Hide popup if click detected elsewhere
<p>I'm trying to hide a div if the user clicks anywhere BUT the popup OR it's children. This is the code I have so far:</p>

<pre><code>$("body").click(function(){
    var $target = $(event.target);
    if(!$target.is(".popup") || !$target.is(".popup").children()){
        $("body").find(".popup").fadeOut().removeClass('active');
    }
});
</code></pre>

<p>It works for the .popup div, but if any of it's children are clicked, it hides it anyway.</p>
