DHTML Methods
DOM Level 1 Specification.
Creates an element node of the specified tag name.
oElement = document.createElement ( sTag )
sTag |
Required. String specifying the name for the new element node. The name is case sensitive. This name is subsequently available as the element node's nodeName property. |
Returns the object for the new element.
This method creates an instance of the element for the specified tagName. Since the instance returned implements an element object, attributes can be specified directly on the returned object.
Although this method creates the new object in the context of this document, this method does not automatically add the new object to the document tree. In other words, although the ownerDocument property of the new node points to this document object, the parentNode property is set to null
. You must explicitly call one of the node insert methods insertBefore, replaceChild, or appendChild to add the new object.
The nodeType has the value NODE_ELEMENT.
All elements can be created stand-alone with the createElement method as of Microsoft® Internet Explorer® version 5 and later. In addition, read-only properties of independently created elements are read/write.
The input object requires a second step when created using createElement. The createElement method generates an input text box because that is the default input type. To insert any other kind of input object, first invoke createElement for input, and then set the type property to the appropriate value in the next line of code.
In Microsoft Internet Explorer® 4.0, only new IMG, AREA, and OPTION elements can be created. Before they can be used, new objects must be explicitly added to their respective collections.
document
add, cloneNode, insertBefore, removeNode