Easy Tutorial
❮ Dom Prop Nodelist Length Prop Cdata Data ❯

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
new_node Required. The node to insert.
existing_node Required. The existing node. The new node is inserted before this node.

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> element:

Example


❮ Dom Prop Nodelist Length Prop Cdata Data ❯