English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
insertAdjacentText()メソッドは、呼び出された要素に対して指定された位置にテキストノードを挿入します。
element.insertAdjacentText(position, text)
var head = document.getElementsByTagName("h2")[0]; head.insertAdjacentText("afterend", "Hello world");テストして見て‹/›
テーブルの数字は、insertAdjacentText()メソッドを完全にサポートする最初のブラウザのバージョンを指定しています:
メソッド | |||||
insertAdjacentText() | は | 48 | は | は | 8 |
引数 | 説明 |
---|---|
position | 要素に対する位置関係。 合法な値:
|
text | 挿入したいテキスト |
返り値: | ありません |
---|---|
例外情况: | SyntaxError-指定された位置(position)認識可能な値ではありません |
「beginbegin」値を使用:
var head = document.getElementsByTagName("h2")[0]; head.insertAdjacentText("afterbegin", "Hello world");テストして見て‹/›
「beforebegin」値を使用:
var head = document.getElementsByTagName("h2")[0]; head.insertAdjacentText("beforebegin", "Hello world");テストして見て‹/›
「beforeend」値を使用:
var head = document.getElementsByTagName("h2")[0]; head.insertAdjacentText("beforeend", "Hello world");テストして見て‹/›
HTML DOM 参考:element.insertAdjacentElement()メソッド
HTML DOM 参考:element.insertAdjacentHTML()メソッド
HTML DOM 参考:node.insertBefore()メソッド
HTML DOM 参考:node.appendChild()メソッド