TOC PREV NEXT INDEX

domref



insertBefore


The insertBefore method allows you to insert a node before a reference element as a child of the current node.

Syntax

insertedElement = element.insertBefore(
   newElement, targetElement)
 

Parameters

insertedElement
The node being inserted.
newElement
The node to insert.
targetElement
The node before which newElement is inserted.

Example

parentDiv = document.getElementById("parentDiv");
 
sp2 = document.getElementById("childSpan");
 
sp1 = document.createElement("span");
 
parentDiv.insertBefore(sp1, sp2);
 

 

Notes

None.

Specification

insertBefore
 


Netscape Communications
http://developer.netscape.com
TOC PREV NEXT INDEX