jquery 鼠标点击其他地方 弹窗消失

JS代码:

//判断:当前元素是否是被筛选元素的子元素 
jQuery.fn.isChildOf = function(b){ return (this.parents(b).length > 0); }; 
//判断:当前元素是否是被筛选元素的子元素或者本身 
jQuery.fn.isChildAndSelfOf = function(b){ return (this.closest(b).length > 0); }; $(document).click(function(event){ alert($(event.target).isChildAndSelfOf(".floatLayer")); });
可判断 当前点击元素是否为某元素本身或子元素,从而决定什么操作
原文地址:https://www.cnblogs.com/hehuiself/p/7099709.html