The answers here are actually not entirely correct. Close, but there is an edge case.
The difference is that $ ('body') actually selects the element by tag name, while document.body refers to a direct object on the document.
This means that if you (or a rogue script) overwrite the document.body (shame!) Element, $ ('body') will still work, but $ (document.body) will not. Therefore, by definition, they are not equivalent.
I would venture to guess that there are other cases of edges (e.g. globally id'ed elements in IE) that will also trigger what constitutes the rewritten body element in the document object, and the same situation would apply.
jvenema 03 Feb '16 at 16:19 2016-02-03 16:19
source share