From 2a8ed6fc9c85c6b8831aeab34e651f0e17d6011b Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Fri, 24 Nov 2023 22:31:54 +0900 Subject: [PATCH] =?UTF-8?q?2023/04/08=20=E6=99=82=E7=82=B9=E3=81=AE?= =?UTF-8?q?=E8=8B=B1=E8=AA=9E=E7=89=88=E3=81=AB=E5=9F=BA=E3=81=A5=E3=81=8D?= =?UTF-8?q?=E6=96=B0=E8=A6=8F=E7=BF=BB=E8=A8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/ja/web/api/range/tostring/index.md | 65 ++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 files/ja/web/api/range/tostring/index.md diff --git a/files/ja/web/api/range/tostring/index.md b/files/ja/web/api/range/tostring/index.md new file mode 100644 index 00000000000000..cf3db773aa81c5 --- /dev/null +++ b/files/ja/web/api/range/tostring/index.md @@ -0,0 +1,65 @@ +--- +title: "Range: toString() メソッド" +short-title: toString() +slug: Web/API/Range/toString +l10n: + sourceCommit: c58e8c1dd6ecbcb63894c7dd17fb9495b9511b4e +--- + +{{ApiRef("DOM")}} + +**`Range.toString()`** メソッドは{{Glossary("stringifier", "文字列化")}}で、 {{domxref("Range")}} のテキストを返します。 + +{{domxref("Range")}} の内容を alert で表示すると、暗黙のうちに `toString()` を呼び出すので、アラートダイアログで範囲とテキストを比較しても効果がありません。 + +## 構文 + +```js-nolint +toString() +``` + +### 引数 + +なし。 + +### 返値 + +文字列です。 + +## 例 + +### HTML + +```html +

+ This example logs everything between the emphasized words. + Look at the output below. +

+

+``` + +### JavaScript + +```js +const range = document.createRange(); + +range.setStartBefore(document.getElementsByTagName("em").item(0), 0); +range.setEndAfter(document.getElementsByTagName("em").item(1), 0); +document.getElementById("log").textContent = range.toString(); +``` + +### 結果 + +{{EmbedLiveSample("Examples")}} + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 + +- [DOM インターフェイス索引](/ja/docs/Web/API/Document_Object_Model)