Document Object

In this chapter you will learn:

  1. Document Object Members
  2. Document Object Events

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

Document Object Events

NameDescription
readystatechangeTriggered when the value of the readyState property changes.

Next chapter...

What you will learn in the next chapter:

  1. How to use document.body to get the body element
Home » Javascript Tutorial » Document
Document Object
document.body
document.characterSet
document.charset
document.compatMode
document.cookie
document.defaultCharset
document.defaultView
getElementsByTagName(tagName)
document.getElementsByClassName
document.getElementsByName
document.images
document.lastModified
document.location
document.implementation
document.querySelectorAll
document.readyState
document.title
document.URL
document.writeln