close when click next to layer
$('.overlay').click(function(e){ if (e.target == e.currentTarget) { $(this).hide(); } });