select document root using jquery

tomsv picture tomsv · Jul 26, 2012 · Viewed 49.7k times · Source

I can select the body and html parts of the document using

$('body')

and

$('html')

respectively, but how do I select the document root?

Answer

adeneo picture adeneo · Jul 26, 2012

Not sure what you mean, but to select the document you do

$(document);

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.

$(document.documentElement);