Last active
March 4, 2024 07:27
-
-
Save mbparvezme/ed6e56dab034013ecd73ba6c811f02c9 to your computer and use it in GitHub Desktop.
This code will check whether you clicked inside the target or not
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
var targetElem = document.querySelector("#sidebar"); | |
window.addEventListener('click',function(e){ | |
if( !targetElem.contains(e.target) && (!document.getElementById('navSwitch').contains(e.target))){ | |
$(targetElem).removeClass('open') | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment