📌  相关文章
📜  javascript 检测元素外的点击 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:07.940000             🧑  作者: Mango

代码示例1
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
    }
});