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')[0] === $(':root')[0]
$(':root')[0] === document.documentElement

Need Your Help

Slashes (`/`) in CSS values when using Less (e.g. in `font` shorthand)

css less

i noticed an issue when using Less with font shorthand

Any way to SQLBulkCopy "insert or update if exists"?

c# .net sql sql-server performance

I need to update a very large table periodically and SQLBulkCopy is perfect for that, only that I have a 2-columns index that prevents duplicates. Is there a way to use SQLBulkCopy as "insert or up...