Is binding a click event to document better than binding it to body?

后端 未结 5 1957
逝去的感伤
逝去的感伤 2021-02-20 15:55

The question is simply between

$(\"body\").click(function(e){}); vs $(document).click(function(e){});

which is more efficient or advisa

5条回答
  •  甜味超标
    2021-02-20 16:26

    Also the body might not cover the whole visible window (some crazy styles cause that)! I don't know if you would still get the click event in this case. So better bind it to document.

提交回复
热议问题