The insertBefore() method is used to insert a node before the reference node as a child of a specified parent node. If the given child is a reference to an existing node in the document, insertBefore( ) moves it from its current position to the new position.
If referenceNode is null, the newNode is inserted at the end of the list of child nodes.
Syntax: –
parentNode.insertBefore(newNode, referenceNode);
insertAdjacentElement ( ) Method
The insertAdjacentElement() method inserts the specified element into a given specified position. It returns the element that was inserted, or null if the insertion failed.
Syntax:-
element – The element to be inserted into the tree.
The beforebegin and afterend positions work only if the node is in a tree and has an element parent.
insertAdjacentHTML ( ) Method
The insertAdjacentHTML() method is used to insert a text as HTML (parses the specified text as HTML or XML) into a specified position.
Syntax:-
text – The string to be parsed as HTML or XML and inserted into the tree.
It is recommended you not use insertAdjacentHTML when inserting plain text instead, use the node.textContent property
insertAdjacentText ( ) Method
The insertAdjacentText() method inserts the specified element into a specified position.
Syntax:-
text – The text which is about to insert.
The beforebegin and afterend positions work only if the node is in a tree and has an element parent.
- Top 10 Customer Experience (CX) Platforms of 2026 (Reviewed by Experts) - March 24, 2026
- Top 10 Call Center Software Tools in 2026 (Reviewed by Experts) - March 24, 2026
- Global PR Points Calculators – Check Your Immigration Eligibility for Australia, Canada, Austria, Japan, New Zealand, and South Korea - March 14, 2026