0% found this document useful (0 votes)
5 views5 pages

Understanding the HTML Document Object

The document object represents the HTML document loaded in the browser. It is the root node of the DOM tree, and provides properties and methods to access all other nodes in the document. The document object can be accessed via the window.document property. It contains properties for metadata like the title, as well as methods for traversing and manipulating the DOM like getElementById().
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Understanding the HTML Document Object

The document object represents the HTML document loaded in the browser. It is the root node of the DOM tree, and provides properties and methods to access all other nodes in the document. The document object can be accessed via the window.document property. It contains properties for metadata like the title, as well as methods for traversing and manipulating the DOM like getElementById().
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

he HTML DOM Document Object

Previous

Next Reference

HTML DOM Nodes


In the HTML DOM (Document Object Model), everything is a node:

The document itself is a document node

All HTML elements are element nodes

All HTML attributes are attribute nodes

Text inside HTML elements are text nodes

Comments are comment nodes

The Document Object


When an HTML document is loaded into a web browser, it becomes
a document object.
The document object is the root node of the HTML document and the
"owner" of all other nodes:
(element nodes, text nodes, attribute nodes, and comment nodes).
The document object provides properties and methods to access all node
objects, from within JavaScript.
Tip: The document is a part of the Window object and can be accessed as
[Link].

Browser Support
Object
Document

Yes

Yes

Yes

Yes

The Document Object is supported in all major browsers.

Document Object Properties and Methods


The following properties and methods can be used on HTML documents:

Property / Method

Description

[Link]

Returns the currently focused element in the document

[Link]()

Attaches an event handler to the document

[Link]()

Adopts a node from another document

[Link]

Returns a collection of all <a> elements in the document that

[Link]

Returns a collection of all <applet> elements in the documen

[Link]

Returns the absolute base URI of a document

[Link]

Sets or returns the document's body (the <body> element)

[Link]()

Closes the output stream previously opened with document.o

[Link]

Returns all name/value pairs of cookies in the document

[Link]()

Creates an attribute node

[Link]()

Creates a Comment node with the specified text

[Link]()

Creates an empty DocumentFragment node

[Link]()

Creates an Element node

[Link]()

Creates a Text node

[Link]

Returns the Document Type Declaration associated with the

[Link]

Returns the Document Element of the document (the <html>

[Link]

Returns the mode used by the browser to render the documen

[Link]

Sets or returns the location of the document

[Link]

Returns the domain name of the server that loaded the docum

[Link]

Obsolete. Returns the DOM configuration of the document

[Link]

Returns a collection of all <embed> elements the document

[Link]

Returns a collection of all <form> elements in the document

[Link]()

Returns the element that has the ID attribute with the specifie

[Link]()

Returns a NodeList containing all elements with the specifie

[Link]()

Returns a NodeList containing all elements with a specified n

[Link]()

Returns a NodeList containing all elements with the specifie

[Link]()

Returns a Boolean value indicating whether the document ha

[Link]

Returns the <head> element of the document

[Link]

Returns a collection of all <img> elements in the document

[Link]

Returns the DOMImplementation object that handles this do

[Link]()

Imports a node from another document

[Link]

Returns the encoding, character set, used for the document

[Link]

Returns the date and time the document was last modified

[Link]

Returns a collection of all <a> and <area> elements in the do


attribute

[Link]()

Removes empty Text nodes, and joins adjacent nodes

[Link]()

Removes empty Text nodes, and joins adjacent nodes

[Link]()

Opens an HTML output stream to collect output from docum

[Link]()

Returns the first element that matches a specified CSS select

[Link]()

Returns a static NodeList containing all elements that matche


selector(s) in the document

[Link]

Returns the (loading) status of the document

[Link]

Returns the URL of the document that loaded the current doc

[Link]()

Removes an event handler from the document (that has been


the addEventListener() method)

[Link]()

Renames the specified node

[Link]

Returns a collection of <script> elements in the document

[Link]

Sets or returns whether error-checking is enforced or not

[Link]

Sets or returns the title of th

You might also like