Sunday, May 16, 2010

JavaScript: document Object

 

The document is the root object that can consists of all the elements enclosed within HTML, HEAD and BODY tags in a web page.

The most common functions to get the element(s) / the element properties are as follows viz.,

  • document.getElementById
  • document.getElementsByName
  • document.getElementsByTagName

The document.getElementById returns the require object of the element searched.

The other two functions return an array object which can be looped to get the individual elements.