SO - 32284158
HTML
<div class="block"></div>
CSS
.block {
width:200px;
height:200px;
background:#ccc;
}
JavaScript
$(document).ready(function () {
// when a block is clicked get that specific block
$('.block').click(function (e) {
e.stopPropagation();
var block = $(this);
block.css('background', 'red');
$('html').css('background', 'none');
});
//if clicked other than the block do stuff
$('html:not(.block)').click(function () {
//your logic here
$(this).css('background', 'green');
$('.block').css('background', '#ccc');
});
});