Last active
August 29, 2015 13:57
-
-
Save dustintheweb/9924104 to your computer and use it in GitHub Desktop.
If you click outside of a specific div, do something
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('body').on('touchstart click', $staticSection, function(e) { | |
var $target = $(e.target); | |
if(!$target.closest($someSection).length) { | |
// do something... ex: $someSection.removeClass('open'); | |
} | |
}); | |
// conditional example | |
$('body').on('touchstart click', $staticSection, function(e) { | |
var $target = $(e.target); | |
if ($('body').is($someClass) && !$target.closest($someSection).length) { | |
// do something... ex: $someSection.removeClass('open'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment