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.
- Best DevOps is redefining the DevOps landscape - January 28, 2025
- Unlocking the Power of DevOps: How DevOps Consulting Drives Business Success - January 23, 2025
- DevOps Support: Ensuring Seamless Operations and Continuous Improvement - January 23, 2025