Javascript Reference
Categories: document

javascript document createElement( )

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

createElement("tagName")

Generates in memory an instance of an element object associated with the tag passed as a parameter to the method. The method is limited to area, img, and option elements in IE 4; all elements are permitted in other supporting browsers. A newly created element has no attribute values assigned (except any default values assigned according to the DTD), nor is the element yet part of the document tree. Assign attributes (such as the type for an input element or id for any element), and append or insert the element into the document tree. This sequence is the W3C DOM approach to generating new content (in place of the innerHTML convenience properties implemented in IE and Netscape 6 browsers).

 
Parameters
 
tagName

A string of the tag name of the new element: document.createElement("option"). IE also allows a complete start tag string, complete with angle brackets and attribute name/value pairs. Only the straight tag name is supported by the W3C DOM specification.

 
Returned Value

Element object reference.


Powered by Linode.