aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasahiro FUJIMOTO <mfujimot@gmail.com>2022-02-26 00:16:32 +0900
committerMasahiro FUJIMOTO <mfujimot@gmail.com>2022-03-05 22:14:26 +0900
commited6203f957a5616efa135b87368715645b251444 (patch)
tree0a391995410e2f3eb5df477b8620296ed64ac856
parent0e7fc92daa74711762322b806e2371ff19d2fed3 (diff)
downloadtranslated-content-ed6203f957a5616efa135b87368715645b251444.tar.gz
translated-content-ed6203f957a5616efa135b87368715645b251444.tar.bz2
translated-content-ed6203f957a5616efa135b87368715645b251444.zip
2021/11/08 時点の英語版に同期
-rw-r--r--files/ja/web/api/node/childnodes/index.md159
-rw-r--r--files/ja/web/api/node/firstchild/index.md103
-rw-r--r--files/ja/web/api/node/lastchild/index.md55
-rw-r--r--files/ja/web/api/node/nextsibling/index.md107
-rw-r--r--files/ja/web/api/node/nodetype/index.md150
-rw-r--r--files/ja/web/api/node/nodevalue/index.md136
-rw-r--r--files/ja/web/api/node/ownerdocument/index.md68
7 files changed, 353 insertions, 425 deletions
diff --git a/files/ja/web/api/node/childnodes/index.md b/files/ja/web/api/node/childnodes/index.md
index 82a90460c6..0e07d3ecb3 100644
--- a/files/ja/web/api/node/childnodes/index.md
+++ b/files/ja/web/api/node/childnodes/index.md
@@ -2,100 +2,73 @@
title: Node.childNodes
slug: Web/API/Node/childNodes
tags:
- - API
- - DOM
- - DOMリファレンス
- プロパティ
- リファレンス
+ - 読み取り専用
+browser-compat: api.Node.childNodes
translation_of: Web/API/Node/childNodes
---
-<p>{{ ApiRef() }}</p>
-
-<p><code><strong>Node.childNodes</strong></code>読み取り専用プロパティは、最初の子ノードにインデックス0が割り当てられている、指定された要素の子{{domxref("Node","nodes")}}の現在の{{domxref("NodeList")}}を返します。</p>
-
-<h2 id="構文">構文</h2>
-
-<pre class="syntaxbox">let <var>nodeList</var> = <var>elementNodeReference</var>.childNodes;
-</pre>
-
-<h2 id=".E6.9B.B8.E5.BC.8F.E3.81.A8.E5.80.A4" name=".E6.9B.B8.E5.BC.8F.E3.81.A8.E5.80.A4">例</h2>
-
-<h3 id="簡単な使用方法">簡単な使用方法</h3>
-
-<pre class="brush:js line-numbers language-js"><code class="language-js"><span class="comment token">// 変数pargは&lt;p&gt;要素へのオブジェクト参照です</span>
-
-<span class="comment token">// まず、pargが子ノードを持っているかをチェックします</span>
-<span class="keyword token">if</span> <span class="punctuation token">(</span>parg<span class="punctuation token">.</span><span class="function token">hasChildNodes</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
- <span class="keyword token">var</span> children <span class="operator token">=</span> parg<span class="punctuation token">.</span>childNodes<span class="punctuation token">;</span>
-
- <span class="keyword token">for</span> <span class="punctuation token">(</span><span class="keyword token">let</span> i <span class="operator token">=</span> <span class="number token">0</span><span class="punctuation token">;</span> i <span class="operator token">&lt;</span> children<span class="punctuation token">.</span>length<span class="punctuation token">;</span> i<span class="operator token">++</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
- <span class="comment token">// for文を使って各ノードにchildren[i]としてアクセスします
- // 注意! NodeListは不変ではないので、ノードを追加したり削除したりするとchildren.lengthは変化します</span>
- <span class="punctuation token">}</span>
-<span class="punctuation token">}</span></code></pre>
-
-<h3 id="ノードから全ての子を削除する">ノードから全ての子を削除する</h3>
-
-<pre class="brush:js line-numbers language-js"><code class="language-js"><span class="comment token">// これは一例ですが、この方法でノードからすべての子ノードを削除することができます</span>
-<span class="comment token">// let box = document.getElementById(/**/)</span>;
-
-<span class="keyword token">while</span> <span class="punctuation token">(</span>box<span class="punctuation token">.</span>firstChild<span class="punctuation token">)</span> <span class="punctuation token">{
- // NodeListは不変ではないので、毎処理ごとにbox.firstChildは変化します</span>
- box<span class="punctuation token">.</span><span class="function token">removeChild</span><span class="punctuation token">(</span>box<span class="punctuation token">.</span>firstChild<span class="punctuation token">)</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span></code></pre>
-
-<h2 id="注記">注記</h2>
-
-<p>ノードのコレクション内の項目はオブジェクトであり、文字列ではありません。node オブジェクトからデータを取得するには、そのプロパティ (たとえば<code>elementNodeReference.childNodes[1].nodeName</code> で名前を取得) を使用します。<br>
- <br>
- <code>document</code>オブジェクト自体には Doctype 宣言と root 要素 の2つの子があり、通常は<code>documentElement</code>と呼ばれます。 ((X)HTML文書ではこれが<code>HTML</code>要素です)<br>
- <br>
- <code>childNodes</code>にはテキストノードやコメントノードなどの非要素ノードを含むすべての子ノードが含まれます。要素のみのコレクションを取得するには、代わりに{{domxref("ParentNode.children")}} を使用してください。</p>
-
-<h2 id="仕様">仕様</h2>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">仕様</th>
- <th scope="col">ステータス</th>
- <th scope="col">コメント</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{SpecName('DOM WHATWG', '#dom-node-childnodes', 'Node.childNodes')}}</td>
- <td>{{Spec2('DOM WHATWG')}}</td>
- <td>変更なし</td>
- </tr>
- <tr>
- <td>{{SpecName('DOM3 Core', 'core.html#ID-1451460987', 'Node.childNodes')}}</td>
- <td>{{Spec2('DOM3 Core')}}</td>
- <td>変更なし</td>
- </tr>
- <tr>
- <td>{{SpecName('DOM2 Core', 'core.html#ID-1451460987', 'Node.childNodes')}}</td>
- <td>{{Spec2('DOM2 Core')}}</td>
- <td>変更なし</td>
- </tr>
- <tr>
- <td>{{SpecName('DOM1', 'level-one-core.html#ID-1451460987', 'Node.childNodes')}}</td>
- <td>{{Spec2('DOM1')}}</td>
- <td>初回定義</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="ブラウザの互換性">ブラウザの互換性</h2>
-
-<p>{{Compat("api.Node.childNodes")}}</p>
-
-<h2 id=".E5.8F.82.E7.85.A7" name=".E5.8F.82.E7.85.A7">関連情報</h2>
-
-<ul>
- <li>{{ domxref("Node.firstChild") }}</li>
- <li>{{ domxref("Node.lastChild") }}</li>
- <li>{{ domxref("Node.nextSibling") }}</li>
- <li>{{ domxref("Node.previousSibling") }}</li>
- <li>{{ domxref("Element.children") }}</li>
-</ul>
+{{APIRef("DOM")}}
+
+**`childNodes`** は {{domxref("Node")}} インターフェイスの読み取り専用プロパティであり、{{domxref("NodeList")}} で指定された要素の子{{domxref("Node", "ノード", "", 1)}}の生きたリストを返し、最初の子ノードは位置 `0` に割り当てられます。子ノードには要素、テキスト、コメントが含まれます。
+
+> **Note:** {{domxref("NodeList")}} が生きたリストであるというのは、新しい子が追加されたり取り除かれたりするたびに、内容が変化するという意味です。
+
+ノードのコレクションの項目はオブジェクトであり、文字列ではありません。ノードオブジェクトからデータを取得するには、そのプロパティを使用してください。例えば、最初の子ノードの名前を取得するには、 `elementNodeReference.childNodes[0].nodeName` を使うことで実現できます。
+
+{{domxref("document")}} オブジェクト自体には 2 つの子があります。文書型宣言と、ルート要素、ふつうは `documentElement` として参照されます。 HTML 文書の場合、後者は {{HTMLElement("html")}} 要素です。
+
+覚えておくべき重要なこととして、 `childNodes` には*すべての*子ノードが含まれ、テキストやコメントなどの要素以外のノードが含まれることです。
+要素のみが含まれるコレクションを取得するのであれば、 {{domxref("Element.children")}} を代わりに使用してください。
+
+## 値
+
+このノードの子を含む生きた {{domxref("NodeList")}} です。
+
+> **Note:** `childNodes` を複数回呼び出しても、*同じ* {{domxref("NodeList")}} が返されます。
+
+## 例
+
+### 単純な使用方法
+
+```js
+// parg は <p> 要素へのオブジェクト参照です
+
+// まず、要素に子ノードがあるかどうかをチェックします
+if (parg.hasChildNodes()) {
+ let children = parg.childNodes;
+
+ for (let i = 0; i < children.length; i++) {
+ // それぞれの子を children[i] として処理します
+ // 注: リストは生きています。子を追加したり取り除いたりすると、リストの `length` が変わります
+ }
+}
+```
+
+### ノードからすべてての子を削除
+
+```js
+// これはあるノードからすべての子を取り除くための一つの方法です
+// box はある要素へのオブジェクト参照です
+
+while (box.firstChild) {
+ // リストは生きているので、呼び出されるたびにインデックスが変わります
+ box.removeChild(box.firstChild);
+}
+```
+
+## 仕様書
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}
+
+## 関連情報
+
+- {{domxref("Node.firstChild")}}
+- {{domxref("Node.lastChild")}}
+- {{domxref("Node.nextSibling")}}
+- {{domxref("Node.previousSibling")}}
+- {{domxref("Element.children")}}
diff --git a/files/ja/web/api/node/firstchild/index.md b/files/ja/web/api/node/firstchild/index.md
index 5a57be3ae9..504cd98284 100644
--- a/files/ja/web/api/node/firstchild/index.md
+++ b/files/ja/web/api/node/firstchild/index.md
@@ -2,45 +2,68 @@
title: Node.firstChild
slug: Web/API/Node/firstChild
tags:
- - DOM
- - Gecko
- - Gecko DOM Reference
- - Node
+ - プロパティ
+ - リファレンス
+browser-compat: api.Node.firstChild
translation_of: Web/API/Node/firstChild
---
-<div>
- {{ApiRef}}</div>
-<h2 id="Summary" name="Summary">概要</h2>
-<p>ノードのツリーの中で最初の子ノード、もしくは子ノードがなければ <code>null</code> を返します。ノードが <code>Document</code> の場合は、その直接の子のリスト内の最初のノードを返します。</p>
-<h2 id="Syntax" name="Syntax">構文</h2>
-<pre class="syntaxbox">var <var>childNode</var> = <var>node</var>.firstChild;
-</pre>
-<ul>
- <li><code>childNode</code> : node の最初の子ノードがあればその参照、無い場合は <code>null</code></li>
-</ul>
-<h2 id="Example" name="Example">例</h2>
-<p>次の例では <code>firstChild</code> の使用方法と、このプロパティを使用すると空白ノードがどのように影響するかをデモンストレーションしています。Gecko DOM に於ける空白の扱われ方についてより多くの情報を得るために、{{Anch("Notes")}} も参照してください。</p>
-<pre class="brush:html">&lt;p id="para-01"&gt;
- &lt;span&gt;First span&lt;/span&gt;
-&lt;/p&gt;
-
-&lt;script type="text/javascript"&gt;
- var p01 = document.getElementById('para-01');
- alert(p01.firstChild.nodeName)
-&lt;/script&gt;</pre>
-<p>上記の例では alert は'#text'を表示します。なぜなら開始タグ &lt;p&gt; の末端と &lt;span&gt; の間にある空白を調整するためにテキストノードが挿入されているからです。<b>どんな</b> 空白、単一スペースから多数のスペース、改行、タブ等々、も #text ノードを挿入することになります。</p>
-<p>その他の #text ノードは閉じタグ &lt;/span&gt; と &lt;/p&gt; の間に挿入されていみます。</p>
-<p>もしこの空白がソースから取り除かれれば、#text ノードは挿入されず、span 要素は段落の最初の子ノードとなります。</p>
-<pre class="brush:html">&lt;p id="para-01"&gt;&lt;span&gt;First span&lt;/span&gt;&lt;/p&gt;
-
-&lt;script type="text/javascript"&gt;
- var p01 = document.getElementById('para-01');
- alert(p01.firstChild.nodeName)
-&lt;/script&gt;
-</pre>
-<p>今度は alert は 'SPAN' を表示するでしょう。</p>
-<h2 id="Specification" name="Specification">仕様書</h2>
-<ul>
- <li><a href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-firstChild">DOM Level 1 Core: firstChild</a></li>
- <li><a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-169727388">DOM Level 2 Core: firstChild</a></li>
-</ul>
+{{APIRef("DOM")}}
+
+**`firstChild`** は {{domxref("Node")}} インターフェイスの読み取り専用プロパティで、ツリー内におけるこのノードの最初の子、またはこのノードに子がない場合は `null` を返します。
+
+このノードが {{domxref("Document")}} であった場合は、このプロパティは直接のこのリスト内で最初のノードを返します。
+
+> **Note:** このプロパティはこのノードの最初の子であれば、あらゆる種類のノードを返します。
+> {{domxref("Text")}} または {{domxref("Comment")}} ノードになることがあります。
+> 他の要素の子である最初の {{domxref("Element")}} を取得したい場合は、 {{domxref("Element.firstElementChild")}} を使用することを検討してください。
+
+## 値
+
+{{domxref("Node")}}、または存在しなければ `null`。
+
+## 例
+
+次の例では `firstChild` の使用方法と、このプロパティを使用すると空白ノードがどのように影響するかを示しています。
+
+```html
+<p id="para-01">
+ <span>最初の span</span>
+</p>
+
+<script>
+ const p01 = document.getElementById('para-01');
+ console.log(p01.firstChild.nodeName);
+</script>
+```
+
+上記の例では[コンソール](/ja/docs/Web/API/console)に '#text' と表示されます。開始タグ `<p>` の末尾と `<span>` タグとの間にある空白を調整するためにテキストノードが挿入されているためです。**あらゆる**[ホワイトスペース](/ja/docs/Web/API/Document_Object_Model/Whitespace)は、単一の空白から複数のスペース、改行、タブに至るまで、 1 つの `#text` ノードを生成します。
+
+`#text` ノードはもう 1 つ、閉じタグ `</span>` と `</p>` の間に挿入されます。
+
+ホワイトスペースをソースから取り除くと、 #text ノードは挿入されず、 span 要素がその段落の最初の子になります。
+
+```html
+<p id="para-01"><span>最初の span</span></p>
+
+<script>
+ const p01 = document.getElementById('para-01');
+ console.log(p01.firstChild.nodeName);
+</script>
+```
+
+コンソールには 'SPAN' と表示されるようになります。
+
+`node.firstChild` が `#text` や `#comment` ノードを返す問題を回避するには、 {{domxref("Element.firstElementChild")}} を使用すると最初の要素ノードのみを返すことができます。
+
+## 仕様書
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}
+
+## 関連情報
+
+- {{domxref("Element.firstElementChild")}}
+- {{domxref("Node.lastChild")}}
diff --git a/files/ja/web/api/node/lastchild/index.md b/files/ja/web/api/node/lastchild/index.md
index e7f5626f3c..9e9d386274 100644
--- a/files/ja/web/api/node/lastchild/index.md
+++ b/files/ja/web/api/node/lastchild/index.md
@@ -2,27 +2,38 @@
title: Node.lastChild
slug: Web/API/Node/lastChild
tags:
- - DOM
- - Gecko
- - Gecko DOM Reference
- - Node
+ - プロパティ
+ - リファレンス
+ - 読み取り専用
+browser-compat: api.Node.lastChild
translation_of: Web/API/Node/lastChild
---
-<div>
- {{ApiRef}}</div>
-<h2 id="Summary" name="Summary">概要</h2>
-<p><strong>lastChild</strong> はノードの子要素の内、最後のものを返します。</p>
-<h2 id="Syntax_and_Values" name="Syntax_and_Values">構文</h2>
-<pre class="syntaxbox">var last_child = element.lastChild
-</pre>
-<h2 id="Description" name="Description">説明</h2>
-<p><code>lastChild</code> として返されるのはノードです。その親が要素であるならば、子ノードは一般的に Element ノード、Text ノード、Comment ノード となります。子要素を持たない場合は <code>null</code> が返されます。</p>
-<h2 id="Example" name="Example">例</h2>
-<pre class="brush:js">var tr = document.getElementById("row1"); // table 要素の特定の行を取得
-var corner_td = tr.lastChild; // 特定の行の内、最後のセルを取得
-</pre>
-<h2 id="Specification" name="Specification">仕様書</h2>
-<ul>
- <li>{{Spec("http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-61AD09FB", "DOM Level 2: lastChild", "REC")}}</li>
- <li>{{Spec("http://dom.spec.whatwg.org/#dom-node-lastchild", "DOM Standard: lastChild")}}</li>
-</ul>
+{{APIRef("DOM")}}
+
+**`lastChild`** は {{domxref("Node")}} インターフェイスの読み取り専用プロパティで、このノードの最後の子ノードを返します。
+親ノードが要素であった場合、子ノードはふつう、要素ノード、テキストノード、コメントノードの何れかです。
+子要素がない場合は `null` を返します。
+
+## Value
+
+このノードの最後の子である {{domxref("Node")}}、または子ノードがなければ `null` です。
+
+## 例
+
+```js
+const tr = document.getElementById("row1");
+const corner_td = tr.lastChild;
+```
+
+## 仕様書
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}
+
+## 関連情報
+
+- {{domxref("Node.firstChild")}}
+- {{domxref("Element.lastElementChild")}}
diff --git a/files/ja/web/api/node/nextsibling/index.md b/files/ja/web/api/node/nextsibling/index.md
index 1ff4c13cef..f310d8e456 100644
--- a/files/ja/web/api/node/nextsibling/index.md
+++ b/files/ja/web/api/node/nextsibling/index.md
@@ -2,86 +2,65 @@
title: Node.nextSibling
slug: Web/API/Node/nextSibling
tags:
- - DOM
- - Gecko
- - Node
- - 要更新
+ - プロパティ
+ - リファレンス
+ - 読み取り専用
+browser-compat: api.Node.nextSibling
translation_of: Web/API/Node/nextSibling
---
-<div>
-<div>
-<div>{{APIRef("DOM")}}</div>
-</div>
+{{APIRef("DOM")}}
-<p><code><strong>Node.nextSibling</strong></code> という読み取り専用プロパティは指定したノードの親の{{domxref("Node.childNodes","子ノード")}}リスト内ですぐ次にあるノードを返し、指定したノードがリストで最後の場合は <code>null</code> を返します。</p>
-</div>
+**`nextSibling`** は {{domxref("Node")}} インターフェイスの読み取り専用プロパティで、指定されたノードの親の {{domxref("Node.childNodes","childNodes")}} の中で、そのすぐ次のノードを返します。または、指定されたノードが親要素の最後の子要素である場合は `null` を返します。
-<h2 id="Syntax" name="Syntax">構文</h2>
+> **Note:** ブラウザーはソースのマークアップにあるホワイトスペースを表すために、文書に {{domxref("Text")}} ノードを挿入します。
+> そのため、例えば [`Node.firstChild`](/ja/docs/Web/API/Node/firstChild) や [`Node.previousSibling`](/ja/docs/Web/API/Node/previousSibling) を使用して得たノードが、取得しようとした実際のノードではなく、ホワイトスペースのテキストノードであることがあります。
+>
+> [DOM でのホワイトスペース](/ja/docs/Web/API/Document_Object_Model/Whitespace)の記事に、この動作に関する詳しい情報があります。
+>
+> {{domxref("Element.nextElementSibling")}} を使用すると、ホワイトスペースのノードや要素間のテキスト、コメントなどを飛ばして次の要素を取得することができます。
+>
+> 子ノードのリストで反対方向に移動する場合は、 [Node.previousSibling](/ja/docs/Web/API/Node/previousSibling) を使用してください。
-<pre class="syntaxbox"><var>nextNode</var> = <var>node</var>.nextSibling
-</pre>
+## 値
-<h2 id="Notes" name="Notes">注記</h2>
+現在のノードの次の兄弟ノードを表す {{domxref("Node")}}、または存在しない場合は `null` です。
-<div>
- <p>Geckoベースのブラウザーはソースマークアップの中で空白を表現するためにテキストノードをドキュメントに挿入します。ですので、例えば <a href="/ja/docs/Web/API/Node/firstChild" title="ノードのツリーの中で最初の子ノード、もしくは子ノードがなければ null を返します。ノードが Document の場合は、その直接の子のリスト内の最初のノードを返します。"><code>Node.firstChild</code></a> や <a href="/ja/docs/Web/API/Node/previousSibling" title="指定のノードの親ノードの childNodes リストの中で直前のノードを返します。また、指定のノードがそのリストの中で先頭の場合は null を返します。"><code>Node.previousSibling</code></a> で得られるノードが、作者が取得しようとした実際の要素ではなく、空白のテキストノードを参照していることがあります。</p>
- <p>より多くの情報を得るには『<a href="/ja/docs/Web/Guide/DOM/Whitespace_in_the_DOM">DOM 中の空白文字</a>』と『<a class="external" href="http://www.w3.org/DOM/faq.html#emptytext" rel="noopener">W3C DOM 3 FAQ: Why are some Text nodes empty?</a>』を参照してください。</p>
+## 例
-<div> </div>
+```html
+<div id="div-1">こちらは div-1 です。</div>
+<div id="div-2">こちらは div-2 です。</div>
+<br/>
+<output><em>計算結果がありません。</em></output>
+```
-<div>{{domxref("Element.nextElementSibling")}} は空白ノードを飛ばして次の要素を得るのに使われます。</div>
-</div>
+```js
+let el = document.getElementById('div-1').nextSibling,
+i = 1;
-<h2 id="Example" name="Example">例</h2>
+let result = "div-1 の兄弟要素:<br/>";
-<pre class="brush:html line-numbers language-html"><code class="language-html"><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>div</span> <span class="attr-name token">id</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>div-01<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>Here is div-01<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>div</span><span class="punctuation token">&gt;</span></span>
-<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>div</span> <span class="attr-name token">id</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>div-02<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>Here is div-02<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>div</span><span class="punctuation token">&gt;</span></span>
+while (el) {
+ result += i + '. ' + el.nodeName+"<br/>";
+ el = el.nextSibling;
+ i++;
+}
-<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>script</span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>text/javascript<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span><span class="language-javascript script token">
-<span class="keyword token">var</span> el <span class="operator token">=</span> document<span class="punctuation token">.</span><span class="function token">getElementById</span><span class="punctuation token">(</span><span class="string token">'div-01'</span><span class="punctuation token">)</span><span class="punctuation token">.</span>nextSibling<span class="punctuation token">,</span>
- i <span class="operator token">=</span> <span class="number token">1</span><span class="punctuation token">;</span>
+const output = document.getElementsByTagName("output")[0];
+output.innerHTML = result;
+```
-console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">'Siblings of div-01:'</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+{{ EmbedLiveSample("Example", "100%", 500)}}
-<span class="keyword token">while</span> <span class="punctuation token">(</span>el<span class="punctuation token">)</span> <span class="punctuation token">{</span>
- console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>i <span class="operator token">+</span> <span class="string token">'. '</span> <span class="operator token">+</span> el<span class="punctuation token">.</span>nodeName<span class="punctuation token">)</span><span class="punctuation token">;</span>
- el <span class="operator token">=</span> el<span class="punctuation token">.</span>nextSibling<span class="punctuation token">;</span>
- i<span class="operator token">++</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span>
+## 仕様書
-</span><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>script</span><span class="punctuation token">&gt;</span></span>
+{{Specifications}}
-/**************************************************
- The following is written to the console as it loads:
+## ブラウザーの互換性
- Siblings of div-01
+{{Compat}}
- 1. #text
- 2. DIV
- 3. #text
- 4. SCRIPT
+## 関連情報
-**************************************************/</code></pre>
-
-<p>上の例で、<code>#text</code> ノードがタグ間のマークアップ内に (つまり、 要素の閉じタグと次の開始タグの間) 空白がある DOM に挿入されているのが見られます。 <code>document.write</code> 文で挿入された要素の間には空白が作成されません。</p>
-
-<p>DOM にテキストノードが入りうるのは DOM が <code>nextSibling</code> を使って横断される時に許可されます。注記のセクションのリソースを見てください。</p>
-
-<h2 id="Specification" name="Specification">仕様</h2>
-
-<ul>
- <li><a href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-nextSibling">DOM Level 1 Core: nextSibling</a></li>
- <li><a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-6AC54C2F">DOM Level 2 Core: nextSibling</a></li>
-</ul>
-
-<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2>
-
-
-
-<p>{{Compat("api.Node.nextSibling")}}</p>
-
-<h2 id="See_also" name="See_also">関連情報</h2>
-
-<ul>
- <li>{{domxref("Element.nextElementSibling")}}</li>
-</ul>
+- {{domxref("Element.nextElementSibling")}}
+- {{domxref("Node.previousSibling")}}
diff --git a/files/ja/web/api/node/nodetype/index.md b/files/ja/web/api/node/nodetype/index.md
index 135f0f95c7..099e980805 100644
--- a/files/ja/web/api/node/nodetype/index.md
+++ b/files/ja/web/api/node/nodetype/index.md
@@ -2,87 +2,73 @@
title: Node.nodeType
slug: Web/API/Node/nodeType
tags:
- - DOM
- - Gecko
- - Gecko DOM Reference
+ - プロパティ
+ - リファレンス
+ - 読み取り専用
+browser-compat: api.Node.nodeType
translation_of: Web/API/Node/nodeType
---
-<div>
- {{ApiRef}}</div>
-<h2 id="Summary" name="Summary">概要</h2>
-<p>ノードの種類を表す整数のコードを返します。</p>
-<h2 id="Syntax" name="Syntax">構文</h2>
-<pre class="syntaxbox">var <var>type</var> = <var>node</var>.nodeType;
-</pre>
-<p><code>type</code> は以下の内の何れかの unsigned short 型の値となります。</p>
-<table>
- <thead>
- <tr>
- <th scope="col">名称</th>
- <th scope="col">値</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>ELEMENT_NODE</code></td>
- <td>1</td>
- </tr>
- <tr>
- <td><code>ATTRIBUTE_NODE</code> {{deprecated_inline}}</td>
- <td>2</td>
- </tr>
- <tr>
- <td><code>TEXT_NODE</code></td>
- <td>3</td>
- </tr>
- <tr>
- <td><code>CDATA_SECTION_NODE</code> {{deprecated_inline}}</td>
- <td>4</td>
- </tr>
- <tr>
- <td><code>ENTITY_REFERENCE_NODE</code> {{deprecated_inline}}</td>
- <td>5</td>
- </tr>
- <tr>
- <td><code>ENTITY_NODE</code> {{deprecated_inline}}</td>
- <td>6</td>
- </tr>
- <tr>
- <td><code>PROCESSING_INSTRUCTION_NODE</code></td>
- <td>7</td>
- </tr>
- <tr>
- <td><code>COMMENT_NODE</code></td>
- <td>8</td>
- </tr>
- <tr>
- <td><code>DOCUMENT_NODE</code></td>
- <td>9</td>
- </tr>
- <tr>
- <td><code>DOCUMENT_TYPE_NODE</code></td>
- <td>10</td>
- </tr>
- <tr>
- <td><code>DOCUMENT_FRAGMENT_NODE</code></td>
- <td>11</td>
- </tr>
- <tr>
- <td><code>NOTATION_NODE</code> {{deprecated_inline}}</td>
- <td>12</td>
- </tr>
- </tbody>
-</table>
-<h2 id="Example" name="Example">例</h2>
-<p>次の例は、ノードの最初の要素がコメントノードであるかをチェックし、そうでない場合にメッセージを表示するものです。</p>
-<pre class="brush:js">var node = document.documentElement.firstChild;
-
-if (node.nodeType != Node.COMMENT_NODE)
- console.log("※社内コーディングルールに沿ったコメントを記述して下さい。");
-</pre>
-<h2 id="Specification" name="Specification">仕様書</h2>
-<ul>
- <li><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-111237558">DOM Level 2 Core: Node.nodeType</a></li>
- <li><a class="external" href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-111237558">DOM Level 3 Core: Node.nodeType</a></li>
- <li><a class="external" href="http://dom.spec.whatwg.org/#node">DOM Standard</a></li>
-</ul>
+{{APIRef("DOM")}}
+
+**`nodeType`** は {{domxref("Node")}} インターフェイスの読み取り専用プロパティであり、整数値でこのノードがなんであるかを識別します。これは様々なノードの種類、例えば {{domxref("Element", "elements")}}, {{domxref("Text", "text")}}, {{domxref("Comment", "comments")}} を見分けます。
+
+## 値
+
+整数値で、このノードの種類を識別します。可能な値は次の通りです。
+
+- `Node.ELEMENT_NODE` (`1`)
+ - : {{HTMLElement("p")}} や {{HTMLElement("div")}} などの {{domxref("Element")}} ノードです。
+- `Node.ATTRIBUTE_NODE` (`2`)
+ - : {{domxref("Element")}} の {{domxref("Attr", "Attribute")}} ノードです。
+- `Node.TEXT_NODE` (`3`)
+ - : {{domxref("Element")}} や {{domxref("Attr")}} の中に存在する {{domxref("Text")}} です。
+- `Node.CDATA_SECTION_NODE`(`4`)
+ - : `<!CDATA[[ … ]]>` のような {{domxref("CDATASection")}} です。
+- `Node.PROCESSING_INSTRUCTION_NODE` (`7`)
+ - : `<?xml-stylesheet … ?>` のような XML 文書の {{domxref("ProcessingInstruction")}} です。
+- `Node.COMMENT_NODE` (`8`)
+ - : `<!-- … -->` のような {{domxref("Comment")}} ノードです。
+- `Node.DOCUMENT_NODE` (`9`)
+ - : {{domxref("Document")}} ノードです。
+- `Node.DOCUMENT_TYPE_NODE` (`10`)
+ - : `<!DOCTYPE html>` のような {{domxref("DocumentType")}} ノードです。
+- `Node.DOCUMENT_FRAGMENT_NODE` (`11`)
+ - : A {{domxref("DocumentFragment")}} node.
+
+`Node.ENTITY_REFERENCE_NODE` (`5`), `Node.ENTITY_NODE` (`6`), `Node.NOTATION_NODE` (`12`) は非推奨になっており、使用されなくなっています。
+
+## 例
+
+## 様々な種類のノード
+
+```js
+document.nodeType === Node.DOCUMENT_NODE; // true
+document.doctype.nodeType === Node.DOCUMENT_TYPE_NODE; // true
+
+document.createDocumentFragment().nodeType === Node.DOCUMENT_FRAGMENT_NODE; // true
+
+const p = document.createElement("p");
+p.textContent = "昔々…";
+
+p.nodeType === Node.ELEMENT_NODE; // true
+p.firstChild.nodeType === Node.TEXT_NODE; // true
+```
+
+### コメント
+
+次の例は、ノードの最初の要素がコメントノードであるかをチェックし、そうでない場合にメッセージを表示するものです。
+
+```js
+const node = document.documentElement.firstChild;
+if (node.nodeType !== Node.COMMENT_NODE) {
+ console.warn("コメントを入れてください。");
+}
+```
+
+## 仕様書
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}
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}}
diff --git a/files/ja/web/api/node/ownerdocument/index.md b/files/ja/web/api/node/ownerdocument/index.md
index f6eef4f570..75cf471b02 100644
--- a/files/ja/web/api/node/ownerdocument/index.md
+++ b/files/ja/web/api/node/ownerdocument/index.md
@@ -2,65 +2,35 @@
title: Node.ownerDocument
slug: Web/API/Node/ownerDocument
tags:
- - DOM
- - Gecko
- - Node
+ - プロパティ
+ - リファレンス
+ - 読み取り専用
+browser-compat: api.Node.ownerDocument
translation_of: Web/API/Node/ownerDocument
---
-<div>{{ApiRef}}</div>
+{{APIRef("DOM")}}
-<h2 id="Summary" name="Summary">概要</h2>
+**`ownerDocument`** は {{domxref("Node")}} インターフェイスの読み取り専用プロパティで、このノードの最上位の文書オブジェクトを返します。
-<p><code>ownerDocument</code> プロパティは、指定ノードを内包するノードツリーのトップレベルのドキュメントオブジェクトを返します。</p>
+## 値
-<h2 id="Syntax" name="Syntax">構文</h2>
+すべての子ノードが作成された最上位の {{domxref("Document")}} オブジェクトです。
-<pre class="syntaxbox"><var>document</var> = element.ownerDocument
-</pre>
+このプロパティが文書自身のノードで使用された場合、値は `null` になります。
-<ul>
- <li><code>document</code> : 指定要素の祖先である {{domxref("document")}} オブジェクト</li>
-</ul>
+## 例
-<h2 id="Example" name="Example">例</h2>
+```js
+// 指定された "p" から、文書オブジェクトの子である最上位の HTML を取得します。
-<pre class="brush:js">var doc = p.ownerDocument; // ノード p のノードツリー上のトップレベル document オブジェクトを取得
-var html = doc.documentElement; // owner のドキュメント要素を取得
+const d = p.ownerDocument;
+const html = d.documentElement;
+```
-alert(html); // [object HTMLHtmlElement]
-</pre>
+## 仕様書
-<h2 id="Notes" name="Notes">注記</h2>
+{{Specifications}}
-<p>このプロパティによって返される <code>document</code> オブジェクトは、実際の HTML 文書中ですべての子ノードの属するメインオブジェクトです。<code>document</code> ノード自身に対しこのプロパティを用いた場合、戻り値は <code>null</code> となります。</p>
+## ブラウザーの互換性
-<h2 id="Browser_compatibility" name="Browser_compatibility">仕様</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th>Specification</th>
- <th>Status</th>
- <th>Comment</th>
- </tr>
- <tr>
- <td>{{SpecName("DOM4", "#dom-node-ownerdocument", "Node.ownerDocument")}}</td>
- <td>{{Spec2("DOM4")}}</td>
- <td> </td>
- </tr>
- <tr>
- <td>{{SpecName("DOM3 Core", "core.html#node-ownerDoc", "Node.ownerDocument")}}</td>
- <td>{{Spec2("DOM3 Core")}}</td>
- <td>No change</td>
- </tr>
- <tr>
- <td>{{SpecName("DOM2 Core", "core.html#node-ownerDoc", "Node.ownerDocument")}}</td>
- <td>{{Spec2("DOM2 Core")}}</td>
- <td>Initial definition</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザ実装状況</h2>
-
-<p>{{Compat("api.Node.ownerDocument")}}</p>
+{{Compat}}