js点击空白处弹窗消失

$(document).mousedown(function(e){
    var _list = $('#pop');
    if(!_list.is(e.target) && _list.has(e.target).length === 0){
        $('#pop').hide();
    }
});

判断点击事件发生在区域外的条件:
1. 点击事件的对象不是目标区域本身
2. 事件对象同时也不是目标区域的子元素

原文地址:https://www.cnblogs.com/naokr/p/5632416.html