Capture a click outside a specific object

  $(document).bind('click', function(event) {
    var $clicked = $(event.target);
    if (!($clicked.is('#id') || $clicked.parents().is('#id'))) {
      // Do something
    }
  });

Leave a Reply