var specifiedElement = document.getElementById(%27a%27); //I%27m using "click" but it works with any event document.addEventListener(%27click%27, function(event) { var isClickInside = specifiedElement.contains(event.target); if (!isClickInside) { //the click was outside the specifiedElement, do something } });