DocumentType:replaceWith() 方法
DocumentType.replaceWith() 方法使用給定的一組節點來替換文件型別。
語法
js
replaceWith(node1)
replaceWith(node1, node2)
replaceWith(node1, node2, /* …, */ nodeN)
引數
node1, …,nodeN-
用於替換
DocumentType的一組節點。
返回值
無(undefined)。
異常
HierarchyRequestErrorDOMException-
在節點無法插入到層次結構中的指定位置時丟擲。
示例
使用 replaceWith()
js
let svg_dt = 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(svg_dt);
規範
| 規範 |
|---|
| DOM # ref-for-dom-childnode-replacewith① |
瀏覽器相容性
載入中…