replaceWith replaces the node with nodes, while replacing strings in the nodes with equivalent text nodes.
node.replaceWith(...nodes)
after
before
remove
Web Hypertext Application Technology Working Group (WHATWG)