I will answer the question in several parts.
In JavaScript (not just jQuery, but all JavaScript), the document keyword is a handle to an object that contains an HTMLDocument. You can use this descriptor in the following scripts ...
When you pass a document to jQuery, it parses the document into a jQuery object.
When you pass the "html" selector to jQuery, it uses this string to search for any elements in the document object model that match the selector (in all cases there will be one html element).
In fact, you will not notice the difference in behavior between them:
$(document).click(function() { alert('blah'); }); $('html').click(function() { alert('blah'); }); $('body').click(function() { alert('blah'); });
But the technical difference is that the document is an object, and "html" is a string that is used to search for an element. Both the object and any corresponding elements are converted to jQuery objects.
Because they all add a click event handler to the "visible" part of the page, which is the only part of the page that the user can actually click on.
Fenton
source share