The insertAfter()
method inserts a new node immediately after a specified reference (child) node in the target node.
If the reference node is not found as a child of the target node, a DOMException
exception will be thrown.
If the new node already exists in the DOM tree, it will be moved to the new position under the target node. This asserts that a node cannot be in two locations at the same time.
Description
public AbstractNode::insertAfter(NodeInterface $newNode, NodeInterface $childNode): ?NodeInterface
Parameters
newNode
The new node to insert after the reference node.
childNode
The existing node after which the new node will be inserted.
Return Value
Returns the newly inserted NodeInterface
object.
Exceptions
NOT_FOUND_ERR
Thrown if reference node is not a child of the target node.