replaceChild

fun <T : Node> replaceChild(node: Node, child: T): T(source)

MDN Reference