Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. DocumentType
  4. replaceWith()

DocumentType: replaceWith() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.

TheDocumentType.replaceWith() method replaces the document type with a set of given nodes.

Syntax

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

Parameters

node1, …,nodeN

A set of nodes to replace theDocumentType with.

Return value

None (undefined).

Exceptions

HierarchyRequestErrorDOMException

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

Examples

UsingreplaceWith()

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

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp