DocumentType: phương thức after()
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.
Phương thức DocumentType.after() chèn một tập hợp các đối tượng Node hoặc chuỗi vào danh sách con của nút cha của DocumentType, ngay sau DocumentType. Các chuỗi sẽ được chèn dưới dạng các nút Text tương ứng.
Cú pháp
js
after(param1)
after(param1, param2)
after(param1, param2, /* …, */ paramN)
Tham số
param1, ...,paramN-
Một tập hợp các đối tượng
Nodehoặc chuỗi để chèn.
Giá trị trả về
Không có (undefined).
Ngoại lệ
HierarchyRequestErrorDOMException-
Được ném ra khi nút không thể được chèn tại điểm đã chỉ định trong cây phân cấp.
Ví dụ
js
let docType = document.implementation.createDocumentType("html", "", "");
let myDoc = document.implementation.createDocument("", "", docType);
docType.after(document.createElement("html"));
myDoc.childNodes;
// NodeList [<!DOCTYPE html>, <html>]
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| DOM> # ref-for-dom-childnode-after①> |