Search code examples
jqueryhtmljquery-selectorsdocument-root

select document root using jquery


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

$('body')

and

$('html')

respectively, but how do I select the document root?


Solution

  • 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);