select document root using jquery
I can select the body and html parts of the document using
respectively, but how do I select the document root?
Not sure what you mean, but to select the document you do
To get the contents of the document I'm guessing you need the documentElement, which is just the same as the <html> tag in most enviroments.
The Document interface inherits from Node, and represents the whole document, such as an HTML page. Although the Document node is conceptually the root of a document, it isn't physically the root - the root node is the first Element node in the Document, and is represented by its documentElement property.
You can select documentElement with following code:
var root = document.documentElement;
The root of the DOM is always the html element. You can get it either with $('html') or $(':root').
The following assertions should always be true:
$('html') === $(':root') $(':root') === document.documentElement