Javascript Reference
Categories: Element

javascript Element applyElement( )

@March 15, 2008, 1:22 a.m.
applyElement( )Firefox/Netscape/NN n/a IE 5(Win) Chrome/Safari/DOM n/a  

applyElement(elementObject[, type])


Inserts a new element as either a child element of the current object or as the new parent of the current object, depending on the value of the second parameter. The default behavior is to wrap the current object with the new element. But you may also choose to insert the new element as a child element. In this case, if the current object is in the document tree (as opposed to simply floating in memory after being created with document.createElement( )) and already has child elements nested inside it, the newly applied element is inserted in such a way that the previous children become children of the inserted element (i.e., grandchildren of the current object). This wrapping behavior is unique among IE element insertion methods and can have significant impact on the document tree. Use with caution.

  • Reference to any dynamically-generated or existing element object from the document tree.
  • Optional string value: inside (the new element becomes the sole, first child of the current object); outside (the new element becomes the parent of the current object). The default is outside.
Returned Value

Reference to the newly added element object.

Powered by Linode.