Skip to content

Instantly share code, notes, and snippets.

@think2011
Created December 30, 2016 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save think2011/8e1877641fe705943e8259c3c2edaedf to your computer and use it in GitHub Desktop.
Save think2011/8e1877641fe705943e8259c3c2edaedf to your computer and use it in GitHub Desktop.
function outerClick(selector, fn) {
$(document).on("click", function (event) {
var isHit = $(event.target).closest(selector).length
if (!isHit) fn.call(fn, event)
})
return function () {
$(document).off('click', fn)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment