jQuery event handling - bind to document or 'body' element?

后端 未结 5 935
长发绾君心
长发绾君心 2020-12-31 01:36

I have noticed the use of $(document) and $(\'body\') when we want to reference the entire page, especially when binding events.

$(         


        
5条回答
  •  暖寄归人
    2020-12-31 02:02

    Body is a child of document. Because of this, events will first reach the body before they are bubbled up to the document.
    example: http://jsfiddle.net/CoryDanielson/JhH9V/

提交回复
热议问题