CharacterData: replaceData() メソッド
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
replaceData()
は CharacterData
インターフェイスのメソッドで、この CharacterData
ノードにある既存のテキストの特定の数の文字を取り除き、指定されたテキストの文字で置き換えます。
構文
js
characterData.replaceData(offset, count, data)
引数
返値
なし。
例外
IndexSizeError
DOMException
-
offset
またはcount
が負の値であるか、offset
が含まれるデータの長さよりも大きい場合に発生します。
例
html
<span>Result: </span>A long string.
js
const span = document.querySelector("span");
const textnode = span.nextSibling;
textnode.replaceData(2, 4, "replaced");
仕様書
Specification |
---|
DOM # dom-characterdata-replacedata |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
replaceData |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.