DocumentType: after() method

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("DOM")}}

The **after()** method of the {{domxref("DocumentType")}} interface inserts a set of {{domxref("Node")}} objects or strings in the children list of the DocumentType's parent, just after the DocumentType. Strings are inserted as equivalent {{domxref("Text")}} nodes. Nothing happens if {{domxref("Node.parentNode", "parentNode")}} is null.

Syntax

js-nolint
after(param1)
after(param1, param2)
after(param1, param2, /* …, */ paramN)

Parameters

  • param1, …, paramN
  • : A set of {{domxref("Node")}} objects or strings to insert.

Return value

None ({{jsxref("undefined")}}).

Exceptions

  • HierarchyRequestError {{DOMxRef("DOMException")}}
  • : Thrown when the node cannot be inserted at the specified point in the hierarchy.

Examples

js
const docType = document.implementation.createDocumentType("html", "", "");
const myDoc = document.implementation.createDocument("", "", docType);

docType.after(document.createElement("html"));

myDoc.childNodes;
// NodeList [<!DOCTYPE html>, <html>]

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("DocumentType.before()")}}
  • {{domxref("CharacterData.after()")}}
  • {{domxref("Element.after()")}}