比如想实现点击列表弹出筛选器,点击其他任意地方关闭筛选器,如图


该筛选器class名

$(document).click(function () {
      $(".subMenu").hide();
});
 $(".subMenu").on("click", function (event) {
      //取消事件冒泡
      var e = arguments.callee.caller.arguments[0] || event; //若省略此句,下面的e改为event,IE运行可以,但是其他浏览器就不兼容
      if (e && e.stopPropagation) {
          // this code is for Mozilla and Opera
          e.stopPropagation();
      } else if (window.event) {
          // this code is for IE
          window.event.cancelBubble = true;
      }
});

首先点击document任意位置隐藏该元素,然后给该元素绑定click事件,阻止冒泡到该元素,则可以顺利实现需求。