📅  最后修改于: 2022-03-11 15:02:54.088000             🧑  作者: Mango
var container = document.getElementsByClassName('container')[0];
document.addEventListener('click', function( event ) {
if (container !== event.target && !container.contains(event.target)) {
console.log('clicking outside the div');
}
});