$(document).click(function(evt) {
var target = evt.currentTarget;
var inside = $(\".menuWraper\");
if (target != inside) {
alert(\"bleep\");
Just have your menuWraper element call event.stopPropagation() so that its click event doesn't bubble up to the document.
Try it out: http://jsfiddle.net/Py7Mu/
$(document).click(function() {
alert('clicked outside');
});
$(".menuWraper").click(function(event) {
alert('clicked inside');
event.stopPropagation();
});
Alternatively, you could return false; instead of using event.stopPropagation();