jquery实现点击div外隐藏div

html

<div style="width:100px;height:100px;border:1px solid #ff0" id="div">div</div>

 

js

 

document.on("click",function(e){

   if($(e.target).closest("#div").length=0){

          $("#div").hide();

    }

})

posted @ 2017-04-17 10:07  东庄  阅读(224)  评论(0编辑  收藏  举报