DocumentType:after() 方法
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Please help us by answering a few questions.
DocumentType.after()
方法在 DocumentType
的父级的子列表中插入一组 Node
对象或字符串,紧跟在 DocumentType
之后。字符串将作为等效的 Text
节点插入。
语法
js
after(param1)
after(param1, param2)
after(param1, param2, /* … ,*/ paramN)
参数
param1
, …,paramN
-
要插入的一组
Node
对象或字符串。
返回值
无 (undefined
)。
异常
HierarchyRequestError
DOMException
-
当无法将节点插入到层次结构的指定点时抛出。
示例
js
let docType = document.implementation.createDocumentType("html", "", "");
let myDoc = document.implementation.createDocument("", "", docType);
docType.after(document.createElement("html"));
myDoc.childNodes;
// 节点列表 [<!DOCTYPE html>, <html>]
规范
Specification |
---|
DOM # ref-for-dom-childnode-after① |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
after |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.