Answers for "javascript detect click outside of element"

7

javascript detect click outside of element

var ignoreClickOnMeElement = document.getElementById('someElementID');

document.addEventListener('click', function(event) {
    var isClickInsideElement = ignoreClickOnMeElement.contains(event.target);
    if (!isClickInsideElement) {
        //Do something click is outside specified element
    }
});
Posted by: Guest on July-22-2019

Code answers related to "javascript detect click outside of element"

Code answers related to "Javascript"

Browse Popular Code Answers by Language