Created
April 17, 2019 03:00
-
-
Save aceraven777/97f2aab0691ff840930418fb52252023 to your computer and use it in GitHub Desktop.
jQuery - If you want to get the clicked element that is outside of a div / section
This file contains 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
$(document).on('click', function (e) { | |
var $clicked = $(e.target); | |
if ($clicked == $('header') || $clicked.parents('header').length) { | |
return; | |
} | |
// Your code here | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment