I am using this code:
$(\'body\').click(function() {
$(\'.form_wrapper\').hide();
});
$(\'.form_wrapper\').click(function(event){
event.stopPropagatio
Here's a jsfiddle I found on another thread, works with esc key also: http://jsfiddle.net/S5ftb/404
var button = $('#open')[0]
var el = $('#test')[0]
$(button).on('click', function(e) {
$(el).show()
e.stopPropagation()
})
$(document).on('click', function(e) {
if ($(e.target).closest(el).length === 0) {
$(el).hide()
}
})
$(document).on('keydown', function(e) {
if (e.keyCode === 27) {
$(el).hide()
}
})