Easy Tutorial
❮ Dom Prop Attr Name Dom Methods ❯

XML DOM insertBefore() Method



Definition and Usage

The insertBefore() method inserts a new child node before an existing child node.

This method returns the new child node.

Syntax

Parameter Description
newchild The new node to insert.
refchild The node before which the new node is inserted.

Example

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc, creates a new <book> node, and inserts it before the last <book> node:

Example


❮ Dom Prop Attr Name Dom Methods ❯