SO Help: Toggle on * click
by SpYk3
HTML
<span id="master">Click to toggle</span>
<div id="slave">Toggle this content</div>
CSS
html, body {
height: 100%;
margin: 0;
padding: 0;
width: 100%;
}
#slave {display: none}
#master, #slave {
cursor: pointer;
}
JavaScript
$('#master').click(function(e) {
e.stopPropagation();
$('#slave').toggle();
});
$('#slave').click(function(e) {
e.stopPropagation();
});
$("body, body *").not('#master, #slave').click(function(e) {
$('#slave').hide();
});