text 「text」にはHTMLやXMLとして挿入することができる文字列を指定します。 下記はinsertAdjacentHTMLのpositionに各値を指定して実行した際の挿入場所を表したものです。コメントの位置に「text」に記述したHTML要素が挿入されます。 <!-- beforebegin --> <div> <!-- afterbegin --> intotheprogram <!-- beforeend --> </div> <!-- afterend --> insertAdjacentHTMLでHTML要素を追加する では、実際に各「position」にHTML要素を追加してみます。下記のHTML要素に対して、段落のタグを追加します。 <div id="box"> <h1>Title</h1> </div> 各「position」を指定した際の実行結果も記載しておりま
![【JavaScript】insertAdjacentHTMLでHTML要素を追加する【挿入位置指定】](https://cdn-ak-scissors.b.st-hatena.com/image/square/adbd203d00ed96c1d1bd5fceb64317b2e2b2bf4a/height=288;version=1;width=512/https%3A%2F%2Finto-the-program.com%2Fuploads%2Finsertadjacenthtml.jpg)