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① |
浏览器兼容性
加载中…