Differences between JQuery calls


Some time ago I was asking myself the following question:

What is the difference between:

  • $(document.body)

  • $('body')

If you could explain me, it would be of great help.


When you make the reference to $(document.body) you directly pass the BODY element to jquery. Whereas when you do $('body') jquery has to look up and interpret the string (in this case body) and find the element.

Some websites explain how response performance changes in different cases.

Having the fastest performance using $(document.body) and the slowest $('body)

here you can find some examples

Scroll to Top