diff options
| author | Masahiro FUJIMOTO <mfujimot@gmail.com> | 2022-02-26 00:16:32 +0900 |
|---|---|---|
| committer | Masahiro FUJIMOTO <mfujimot@gmail.com> | 2022-03-05 22:14:26 +0900 |
| commit | ed6203f957a5616efa135b87368715645b251444 (patch) | |
| tree | 0a391995410e2f3eb5df477b8620296ed64ac856 /files/ja/web/api/node/nodevalue | |
| parent | 0e7fc92daa74711762322b806e2371ff19d2fed3 (diff) | |
| download | translated-content-ed6203f957a5616efa135b87368715645b251444.tar.gz translated-content-ed6203f957a5616efa135b87368715645b251444.tar.bz2 translated-content-ed6203f957a5616efa135b87368715645b251444.zip | |
2021/11/08 時点の英語版に同期
Diffstat (limited to 'files/ja/web/api/node/nodevalue')
| -rw-r--r-- | files/ja/web/api/node/nodevalue/index.md | 136 |
1 files changed, 61 insertions, 75 deletions
diff --git a/files/ja/web/api/node/nodevalue/index.md b/files/ja/web/api/node/nodevalue/index.md index 2cfbbf795f..2d254b0a33 100644 --- a/files/ja/web/api/node/nodevalue/index.md +++ b/files/ja/web/api/node/nodevalue/index.md @@ -2,80 +2,66 @@ title: Node.nodeValue slug: Web/API/Node/nodeValue tags: - - DOM - - Gecko - - Gecko DOM Reference - - Node + - プロパティ + - リファレンス +browser-compat: api.Node.nodeValue translation_of: Web/API/Node/nodeValue --- -<div> - {{ApiRef}}</div> -<h2 id="Summary" name="Summary">概要</h2> -<p>ノードの値を取得または設定します。</p> -<h2 id="Syntax" name="Syntax">構文</h2> -<pre class="syntaxbox"><var>value</var> = <var>node</var>.nodeValue</pre> -<p><code><var>node</var>.nodeValue</code> が存在する場合、 <code>value</code> はノードの値を含む文字列です。</p> -<h2 id="Notes" name="Notes">注記</h2> -<p>document 自身は、 <code>nodeValue</code> は <code>nullを返します。</code>text</p> -<p>ノード、 <code>comment</code> ノード、<code>CDATA</code> ノードでは、 <code>nodeValue</code> はノードの中身を返します。 <code>attribute</code> ノードは属性値を返します。</p> -<p> </p> -<p>以下の表は、 様々なノードの戻り値を表しています。</p> -<table> - <thead> - <tr> - <th>Attr</th> - <th>attribute の値</th> - </tr> - </thead> - <tbody> - <tr> - <td>CDATASection</td> - <td>CDATA Sectionの中身</td> - </tr> - <tr> - <td>コメント</td> - <td>commentの中身</td> - </tr> - <tr> - <td>Document</td> - <td>null</td> - </tr> - <tr> - <td>DocumentFragment</td> - <td>null</td> - </tr> - <tr> - <td>DocumentType</td> - <td>null</td> - </tr> - <tr> - <td>Element</td> - <td>null</td> - </tr> - <tr> - <td>NamedNodeMap</td> - <td>null</td> - </tr> - <tr> - <td>EntityReference</td> - <td>null</td> - </tr> - <tr> - <td>Notation</td> - <td>null</td> - </tr> - <tr> - <td>ProcessingInstruction</td> - <td>ターゲットを除く全体の内容</td> - </tr> - <tr> - <td>Text</td> - <td>the text nodeの中身</td> - </tr> - </tbody> -</table> -<p><code>nodeValue</code> が <code>null</code> と定義されている場合、値を設定しても効果はありません。</p> -<h2 id="Specification" name="Specification">仕様書</h2> -<ul> - <li><a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-F68D080">DOM Level 2 Core: Node.nodeValue</a></li> -</ul> +{{APIRef("DOM")}} + +**`nodeValue`** は {{domxref("Node")}} インターフェイスのプロパティで、現在のノードの値を返したり設定したりします。 + +## Value + +もしあれば、現在のノードの値を含む文字列です。 +文書自身においては、 `nodeValue` は `null` を返します。 +テキスト、コメント、 CDATA ノードでは、 `nodeValue` はノードの内容を返します。 +属性ノードにおいては、属性の値が返します。 + +以下の表はノードの種類別の返値を表しています。 + +| ノード | nodeValue の値 | +| ------------------------------------ | ----------------------------------- | +| {{domxref("CDATASection")}} | CDATA セクションの中身 | +| {{domxref("Comment")}} | コメントの中身 | +| {{domxref("Document")}} | `null` | +| {{domxref("DocumentFragment")}} | `null` | +| {{domxref("DocumentType")}} | `null` | +| {{domxref("Element")}} | `null` | +| {{domxref("NamedNodeMap")}} | `null` | +| {{domxref("ProcessingInstruction")}} | 対象を除く内容物全体 | +| {{domxref("Text")}} | テキストノードの中身 | + +> **Note:** `nodeValue` が `null` になると定義されている場合は、設定しても効果がありません。 + +## 例 + +```html +<div id="d1">Hello world</div> +<!-- コメントの例 --> +<output id="result">結果が出ていません。</output> +``` + +また、以下のスクリプトを参照してください。 + +```js +let node = document.getElementsByTagName("body")[0].firstChild; +let result = "<br/>ノード名:<br/>"; +while (node) { + result += node.nodeName + "の値: " + node.nodeValue + "<br/>"; + node = node.nextSibling +} + +const output = document.getElementById("result"); +output.innerHTML = result; +``` + +{{ EmbedLiveSample("Example", "100%", "250")}} + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} |
