jQuery trigger event when click outside the element

前端 未结 11 562
无人共我
无人共我 2020-12-29 02:35
$(document).click(function(evt) {
    var target = evt.currentTarget;
    var inside = $(\".menuWraper\");
    if (target != inside) {
        alert(\"bleep\");
             


        
11条回答
  •  孤独总比滥情好
    2020-12-29 03:08

    $(document).click((e) => {
      if ($.contains($(".the-one-you-can-click-and-should-still-open").get(0), e.target)) {
      } else {
        this.onClose();
      }
    }); 
    

提交回复
热议问题