Use jQuery to hide a DIV when the user clicks outside of it

后端 未结 30 3520
庸人自扰
庸人自扰 2020-11-21 04:28

I am using this code:

$(\'body\').click(function() {
   $(\'.form_wrapper\').hide();
});

$(\'.form_wrapper\').click(function(event){
   event.stopPropagatio         


        
30条回答
  •  滥情空心
    2020-11-21 05:18

    dojo.query(document.body).connect('mouseup',function (e)
    {
        var obj = dojo.position(dojo.query('div#divselector')[0]);
        if (!((e.clientX > obj.x && e.clientX <(obj.x+obj.w)) && (e.clientY > obj.y && e.clientY <(obj.y+obj.h))) ){
            MyDive.Hide(id);
        }
    });
    

提交回复
热议问题