Document.createElement() (Method)

A method to create a new element within a document.

Availability:

DOM level - 1
JavaScript - 1.5
JScript - 3.0
Internet Explorer - 4.0
Netscape - 6.0
Property/method value type:Element object
JavaScript syntax:-myDocument.createElement(aTagName)
Argument list:aTagNameAn HTML tag name

The result of calling this method is a new Elementobject as if it had been freshly instantiated by an HTML tag.

This is a means of creating new objects which you can then assign to various properties. It is effectively a constructor which is driven by the HTML tag names.

Internally, the MSIE browser maintains objects that are associated with HTML tags as members of a class named after the tag that created them. It's as if there were a class that corresponded to each HTML tag. This means that a call like createElement()can use them as if they were constructor objects.

The internal mechanisms in Netscape 6.0 follow the DOM level 1 specification more closely and use the correct class names as defined in the standards. MSIE may support these in the future and you should be careful when writing any script that needs to be aware of the object class names it is operating on.

See also:Document object, Element object