Javascript Reference
Categories: Element

javascript Element id

@March 15, 2008, 1:22 a.m.
idFirefox/Netscape/NN 6 IE 4 Chrome/Safari/DOM 1  

Read/Write  

Specifies a unique identifier that distinguishes this element from all the rest in the document. The value of this property is most often used to assemble references to elements, but you can loop through all elements to see if there is a match of an id value. It is generally not a good idea to change this property's value for an element already in the document tree. But if a script creates a new element object (via the document.createElement( ) method, for instance), it can assign a unique identifier to this object's id property, and then add the element to the document tree.

 
Example
 
var headID = document.getElementsByTagName("head")[0].id;
 
Value

String.

 
Default

Empty string.


Powered by Linode.