Feb 23, 2011

Detect click outside an element using jQuery

$(document).bind('click', function(e){
var $clicked = $(e.target);
if (!($clicked.is('#element') || $clicked.parents().is('#element'))) {
//click outside, do what you want :)
}
else {
// click inside, to what you want, or nothing :)
}
});

No comments:

Post a Comment

Test post after a long time

i want to see the post