Function: insertAfter()
ts
function insertAfter<T>(newNode, referenceNode): T;Inserts a node after a reference node.
Type Parameters
| Type Parameter |
|---|
T extends Node |
Parameters
| Parameter | Type | Description |
|---|---|---|
newNode | T | The node to insert. |
referenceNode | Node | The reference node. |
Returns
T
The inserted node.
Example
ts
const parent = document.createElement('div')
const a = document.createElement('span')
const b = document.createElement('span')
parent.appendChild(a)
insertAfter(b, a)
parent.children.length // => 2Since
1.0.0