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

后端 未结 5 1973
逝去的感伤
逝去的感伤 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:29

    Binding it to document seems to be the standard practice, so I would stick with that.

    document is also much faster.

提交回复
热议问题