How to make a click on a child element not be considered a click on it's parent in jQuery?
<p>The question of how to detect a click on anywhere except a specified element has been answered a couple of items like here:</p>

<p><a href="http://stackoverflow.com/questions/321239/event-on-a-click-everywhere-on-the-page-outside-of-the-specific-div">Event on a click everywhere on the page outside of the specific div</a></p>

<p>The problem I have is trying to figure out how to detect a click anywhere except a given element including one of it's children.</p>

<p>For example in this code:</p>

<p><a href="http://jsfiddle.net/K5cEm/" rel="nofollow">http://jsfiddle.net/K5cEm/</a></p>

<pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
$(function() {

$(document).click(function(e) {
   $('#somediv').hide();
});
$('#somediv').click(function(e) {
   e.stopPropagation();
});

});
&lt;/script&gt;

&lt;div style="border: 1px solid red; width:100px; height: 100px" id="somediv"&gt;

    &lt;span style="display: block; border: 1px solid green; width:50px; height: 50px; margin: 0 auto" id="someSpan"&gt;&lt;/span&gt;

&lt;/div&gt;
</code></pre>

<p>Clicking anywhere outside the red div should cause it to hide. Not only that but also clicking on it's child element (the green span) should cause it to hide. The only time it shouldn't hide is if you click on it but not on the span. As it stands now, the click on the span is also considered a click on the parent div hence it doesn't hide the div if the span is clicked.</p>

<p>How to achieve this?</p>
