Possible Duplicate:
Detect click outside element?
Im trying to hide a div when focus (click) is outside it, but there are some elements in it and instead of doing the e.target.id on all these is there a way to include all elements? is it clear what i mean?
EDIT: im trying to hide
the #contain_name
when anybody click
outside the newsletter
jsfiddle: demo
<div id="newsletter">
<form action="#" class="form-post">
<div class="clearfix">
<input type="text" id="email" name="email" placeholder="email" />
<button id="fake">Send</button>
</div>
<div id="contain_name" class="clearfix">
<input type="text" id="person_name" placeholder="full name" />
<button id="real_button">Send</button>
</div>
</form>
</div>
$('#email').focus(function() {
$('#fake').fadeOut();
$('#contain_name').slideDown();
});
$(document).on('click', function(){
//do something here
});