Range: cloneContents() メソッド
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.
Range.cloneContents()
は、 Range
に含まれる Node
型のオブジェクトをコピーした DocumentFragment
を返します。
addEventListener()
を使用して追加されたイベントリスナーは、クローン作成中には複製されません。 HTML 属性のイベントは、 Node.cloneNode()
メソッドの場合と同様に複製されます。メソッドと同じです。 HTML の id
属性も複製されますが、これは複製によって無効な文書になる可能性があります。
部分的に選択されたノードは、文書フラグメントを有効にするために必要な親タグが含まれます。
構文
js
cloneContents()
引数
なし。
返値
DocumentFragment
オブジェクトです。
例
js
range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
documentFragment = range.cloneContents();
document.body.appendChild(documentFragment);
仕様書
Specification |
---|
DOM # dom-range-clonecontents |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
cloneContents |
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.