このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

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 ⁨2018年4月⁩.

DocumentType.after() は、一連の Node オブジェクトまたは文字列を、この DocumentType の親ノードの子リストの、この 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;
// NodeList [<!DOCTYPE html>, <html>]

仕様書

Specification
DOM
# ref-for-dom-childnode-after①

ブラウザーの互換性

関連情報