DocumentType:after() 方法
DocumentType.after() 方法會在 DocumentType 的父節點中,在 DocumentType 之後插入一個或多個 Node 物件或字串。字串會被插入為等效的 Text 節點。
語法
js
after(param1)
after(param1, param2)
after(param1, param2, /* …, */ paramN)
引數
param1, …,paramN-
要插入的一組
Node物件或字串。
返回值
無(undefined)。
異常
HierarchyRequestErrorDOMException-
在節點無法插入到層次結構中的指定位置時丟擲。
示例
js
let docType = document.implementation.createDocumentType("html", "", "");
let myDoc = document.implementation.createDocument("", "", docType);
docType.after(document.createElement("html"));
myDoc.childNodes;
// NodeList [<!DOCTYPE html>, <html>]
規範
| 規範 |
|---|
| DOM # ref-for-dom-childnode-after① |
瀏覽器相容性
載入中…