mouse click somewhere else on page (not on a specific div)

前端 未结 4 522
盖世英雄少女心
盖世英雄少女心 2020-12-11 15:29

I want to close a little pop-up box in page when user has clicked anywhere on the page other than box area. how to find it?

4条回答
  •  余生分开走
    2020-12-11 16:07

    @jAndy's solution is good, but I wanted to mention Ben Alman's "Outside Events" plugin as well. Here's a quick example using it:

    $("#popup").bind("clickoutside", function(event){
      $(this).hide();
    });
    

提交回复
热议问题