MDN Web Docs

Syntax

js

replaceWith(node1)
replaceWith(node1, node2)
replaceWith(node1, node2, /* …, */ nodeN)

Parameters

node1, …, nodeN

A set of nodes to replace the DocumentType with.

Return value

None (undefined).

Exceptions

HierarchyRequestError DOMException

Thrown when the node cannot be inserted at the specified point in the hierarchy.

Examples

Using replaceWith()

js

let svgDt = document.implementation.createDocumentType(
  "svg:svg",
  "-//W3C//DTD SVG 1.1//EN",
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd",
);
document.doctype.replaceWith(svgDt);

Specifications

Specification
DOM
# ref-for-dom-childnode-replacewith①

Browser compatibility

See also

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗