Document is an interface that represents the web pages. It serves as an entry point into the content of web pages i.e DOM Tree.
document includes everything about the webpage both which is visible and which is not visible on screen.
A large amount of information about the webpage is also available with the
document, which can be accessed by properties and methods provided by the document.
HTML document implements HTMLDocument interface while XML and SVG documents implements XMLDocument interface.
Document is used to create a new document. Example:
Example: new Document()
document object has a bunch of methods which we use to grab the elements, write something in document, create new element in document, delete older element and much more.
|Methods or Property||Description|
|Document.activeElement||It returns element cursor is focusing to in document|
|Document.addEventListener||It attaches event handler to the element|
|Document.all||It return collection of all elements present in the document|
|Document.anchors||Returns all anchor tag present in the document which has name attribute|
|Document.baseURI||It returns base URI of the document|
|Document.body||It return body of document as an object|
|Document.characterSet||It returns character encoding for the document|
|Document.doctype||Returns the Document type Definition of the document|
|Document.documentElement||Returns the element that is direct child to the document|
|Document.documentURI||Returns document URI as a string|
|Document.forms||Returns a collection of all forms present in the document|
|Document.head||It return head of document as an object|
|Document.scripts||Returns all script element on the document|
|Document.title||It return title of document as an object|