The Document Object
The Document Members
Name | Description | Returns |
---|---|---|
activeElement | Currently focused element. | HTMLElement |
body | body element. | HTMLBodyElement |
characterSet | document character set encoding. (read-only property). | string |
charset | Gets or sets the document character set encoding. | string |
childNodes | Returns the set of child elements. | HTMLElement[] |
compatMode | Gets compatibility mode for the document. | string |
cookie | Gets or sets the cookies. | string |
defaultCharset | Gets the default character encoding. | string |
defaultView | Returns the Window object. | Window |
dir | Gets or sets the text direction. | string |
domain | Gets or sets the domain. | string |
embeds/plugins | Returns objects representing all the embed elements. | HTMLCollection |
firstChild | the first child element of an element. | HTMLElement |
forms | all the form elements in the document. | HTMLCollection |
getElementById(<id>) | get the element by id. | HTMLElement |
getElementsByClassName(<class>) | get the elements by class. | HTMLElement[] |
getElementsByName(<name>) | get the elements by name. | HTMLElement[] |
getElementsByTagName(<tag>) | get the elements by type. | HTMLElement[] |
hasChildNodes() | Returns true if the current element has child elements. | boolean |
head | get the head element. | HTMLHeadElement |
images | get all the img elements. | HTMLCollection |
implementation | Provides information about the available DOM features. | DOMImplementation |
lastChild | get the last child element. | HTMLElement |
lastModified | get the last modified time of the document. | string |
links | get all the a and area elements that have href attributes. | HTMLCollection |
location | get the URL of the current document. | Location |
nextSibling | get the sibling element defined after the current element. | HTMLElement |
parentNode | get the parent element. | HTMLElement |
previousSibling | get the sibling element defined before the current element. | HTMLElement |
querySelector(<selector>) | get the first element that matches the specified CSS selector. | HTMLElement |
querySelectorAll(<selector>) | get all of the elements that match the specified CSS selector. | HTMLElement[] |
readyState | get the state of the current document. | string |
referrer | Returns the URL of the document that linked to the current document (this is the value of the corresponding HTTP header). | string |
scripts | Returns objects representing all the script elements. | HTMLCollection |
styleSheets | access the CSS stylesheets available in your document | CSSStyleSheet |
title | Gets or sets the document title. | string |
The Document Object Events
Name | Description |
---|---|
readystatechange | Triggered when the value of the readyState property changes. |
Home
JavaScript Book
DOM
JavaScript Book
DOM
Document:
- The Document Object
- document.body returns the body element as HTMLBodyElement
- document.characterSet returns document character set encoding
- document.charset gets or sets the document character set encoding
- document.compatMode
- document.cookie reads and writes cookies
- document.defaultCharset gets the default character encoding
- document.defaultView
- document.getElementsByTagName( tagName )
- document.getElementsByClassName ( className )
- document.getElementsByName ( nameOfNameAttribute )
- document.images gets all the img elements and returns HTMLCollection storing all images
- document.lastModified returns the last modified time of the document
- document.location returns the URL of the current document as Location class
- document.implementation property has information about the implementation of the DOM features
- document.querySelectorAll gets all of the elements that match the specified CSS selector
- document.readyState
- document.title returns the document title, changes the document title
- document.URL property returns the URL of the current document
- document.writeln() appends content to the end of the HTML document
- Using Properties to Obtain Element Objects