handleman
12/5/2014 - 1:26 PM

hide element when user clicks outside the element

hide element when user clicks outside the element

$.fn.hideOnClickOutside = function () {
  target = $(this);
  $(document).on('click', function() {
    target.hide();
  });
  target.click( function(event) {
    event.stopPropagation();
  });
  return target;
}