The Document Object

The Document Members

NameDescriptionReturns
activeElementCurrently focused element.HTMLElement
bodybody element.HTMLBodyElement
characterSetdocument character set encoding. (read-only property).string
charsetGets or sets the document character set encoding.string
childNodesReturns the set of child elements.HTMLElement[]
compatModeGets compatibility mode for the document.string
cookieGets or sets the cookies.string
defaultCharsetGets the default character encoding.string
defaultViewReturns the Window object.Window
dirGets or sets the text direction.string
domainGets or sets the domain.string
embeds/pluginsReturns objects representing all the embed elements.HTMLCollection
firstChildthe first child element of an element.HTMLElement
formsall 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
headget the head element.HTMLHeadElement
imagesget all the img elements.HTMLCollection
implementationProvides information about the available DOM features.DOMImplementation
lastChildget the last child element.HTMLElement
lastModifiedget the last modified time of the document.string
linksget all the a and area elements that have href attributes.HTMLCollection
locationget the URL of the current document.Location
nextSiblingget the sibling element defined after the current element.HTMLElement
parentNodeget the parent element.HTMLElement
previousSiblingget 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[]
readyStateget the state of the current document.string
referrerReturns the URL of the document that linked to the current document (this is the value of the corresponding HTTP header).string
scriptsReturns objects representing all the script elements.HTMLCollection
styleSheetsaccess the CSS stylesheets available in your documentCSSStyleSheet
titleGets or sets the document title.string

The Document Object Events

NameDescription
readystatechangeTriggered when the value of the readyState property changes.
Home 
  JavaScript Book 
    DOM  

Document:
  1. The Document Object
  2. document.body returns the body element as HTMLBodyElement
  3. document.characterSet returns document character set encoding
  4. document.charset gets or sets the document character set encoding
  5. document.compatMode
  6. document.cookie reads and writes cookies
  7. document.defaultCharset gets the default character encoding
  8. document.defaultView
  9. document.getElementsByTagName( tagName )
  10. document.getElementsByClassName ( className )
  11. document.getElementsByName ( nameOfNameAttribute )
  12. document.images gets all the img elements and returns HTMLCollection storing all images
  13. document.lastModified returns the last modified time of the document
  14. document.location returns the URL of the current document as Location class
  15. document.implementation property has information about the implementation of the DOM features
  16. document.querySelectorAll gets all of the elements that match the specified CSS selector
  17. document.readyState
  18. document.title returns the document title, changes the document title
  19. document.URL property returns the URL of the current document
  20. document.writeln() appends content to the end of the HTML document
  21. Using Properties to Obtain Element Objects