How to know if a clicked element is inside a main one with jQuery?

This question already has an answer here:

  • How do I detect a click outside an element? 76 answers

  • 你可以试试这个 -

    $(document.body).on('click',function(e){
      if(!$(e.target).closest('#main-space').length){
            $('#main-space').hide();
      }
    });
    
    链接地址: http://www.djcxy.com/p/14716.html

    上一篇: 检查点击模式窗口内部或外部是否发生

    下一篇: 如何知道点击元素是否在jQuery的主要元素之内?