<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><section><h1>処理</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="7" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[7]</anchor-end> <var>節点</var>と<var>識別子</var>について<dfn>識別子により要素を取得</dfn>する処理は、次の場面で使われます。<figure class="list middle"><ul><li><code class="DOMm" xml:lang="en">getElementById</code></li><li><code class="DOMi" xml:lang="en">HTMLElement</code> として<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">反映</anchor></li></ul></figure></p></section><section><h1>関連</h1><ul><li><code class="DOMm" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">getElementsByName</anchor></code></li><li><code class="JS" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">document.all</anchor></code></li><li><code class="DOMm" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">getElementsByTagName</anchor></code></li><li><code class="DOMm" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">getElementsByClassName</anchor></code></li><li><code class="DOMm" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">querySelector</anchor></code>, <code class="DOMm" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">querySelectorAll</anchor></code></li></ul></section><section><h1>歴史</h1><section><h1>W3C DOM 時代</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="3" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[3]</anchor-end>
仕様書:<ul><li><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">DOM水準1</anchor><ul><li>HTML モジュール <code class="DOMi"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTMLDocument</anchor></code> 界面 
<code class="DOMm">getElementById</code> メソッド
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="IW" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="DOM1:&quot;level-one-html.html#ID-36113835&quot;">IW:DOM1:&quot;level-one-html.html#ID-36113835&quot;</anchor-external></li></ul></li><li><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">DOM水準2</anchor><ul><li>中核モジュール <code class="DOMi"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Document</anchor></code> 界面 
<code class="DOMm">getElementById</code> メソッド
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="IW" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="DOM2:&quot;Core/core.html#ID-getElBId&quot;">IW:DOM2:&quot;Core/core.html#ID-getElBId&quot;</anchor-external></li></ul></li><li><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">DOM水準3</anchor><ul><li>中核モジュール <code class="DOMi"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Document</anchor></code> 界面 
<code class="DOMm">getElementById</code> メソッド
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="IW" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="DOM3:&quot;Core/core.html#ID-getElBId&quot;">IW:DOM3:&quot;Core/core.html#ID-getElBId&quot;</anchor-external></li><li>XPath モジュール適合性
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="IW" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="DOM3:&quot;XPath/xpath.html#Conformance&quot;">IW:DOM3:&quot;XPath/xpath.html#Conformance&quot;</anchor-external></li></ul></li></ul></p></section><section><h1>getElementById method (DOM 2+ Document 界面)</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="1" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[1]</anchor-end> Method
<code><var>(<code>(DOMi)<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[Element</anchor></code>)</var> := <var class="DOMi"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Document</anchor></var>.<code class="DOMm">getElementById</code> (<var><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:"><code xmlns="http://www.w3.org/1999/xhtml" class="DOMi"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">DOMString</anchor></code>) <code xmlns="http://www.w3.org/1999/xhtml" class="DOMp">elementId</code></anchor>)</var></code>
を使うと、文書内で<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">識別子属性</anchor> <var class="DOMp">elementId</var>
を持つ<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">要素節</anchor>を得ることができます。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="2" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[2]</anchor-end>
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">妥当</anchor>でないために同じ識別子を持つ要素が複数あるときの動作は未定義です。</p><p>該当するものがないときや、識別子属性を実装が知らない時は
<code class="DOM"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">null</anchor></code> が返ります。</p><p>例外はありません。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="4" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[4]</anchor-end>
文書木から削除されているとか <code class="DOMi"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Entity</anchor></code> 木に存在している識別子つき要素節点とは一致するのでしょうかね?</p></section><section><h1></h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="8" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[8]</anchor-end>
<cite xml:lang="en">Re: Selectors API: Multiple elements with the same ID from Boris Zbarsky on 2007-01-28 (public-webapi@w3.org from January 2007)</cite> (<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Boris Zbarsky (bzbarsky@mit.edu)</anchor> 著, <code>2007-01-28 13:54:06 +09:00</code> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="http://lists.w3.org/Archives/Public/public-webapi/2007Jan/0158">http://lists.w3.org/Archives/Public/public-webapi/2007Jan/0158</anchor-external>
(<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">名無しさん</anchor>)</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="9" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[9]</anchor-end>
<cite>subtech - MisuzillaSubtechImpl - document.getElementById('name');</cite> (<code>2007-05-26 11:40:20 +09:00</code> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="http://subtech.g.hatena.ne.jp/mayuki/20070525/1180091603">http://subtech.g.hatena.ne.jp/mayuki/20070525/1180091603</anchor-external>
(<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">名無しさん</anchor> <weak xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">2007-05-26 02:41:40 +00:00</weak>)</p><p><cite>document.getElementById('name'); - ういはるかぜの化学 - subtech</cite> (<time>2019-07-27 17:12:04 +09:00</time>) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://web.archive.org/web/20190727081152/http://subtech.g.hatena.ne.jp/mayuki/20070525/1180091603">https://web.archive.org/web/20190727081152/http://subtech.g.hatena.ne.jp/mayuki/20070525/1180091603</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="10" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[10]</anchor-end>
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">DOM水準3</anchor>によると<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">識別子属性</anchor>かどうかの判断に <code class="DOMa" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">isId</anchor></code>
を使うことが<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">実装</anchor>には期待されています。</p><comment-p xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:">期待だけかよ。。。</comment-p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="12" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[12]</anchor-end>
<cite xml:lang="en">Beware of id and name attribute mixups when using getElementById in Internet Explorer | 456 Berea Street</cite> (<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Roger Johansson</anchor> 著, <time>2008-03-16 11:16:02 +09:00</time> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="http://www.456bereastreet.com/archive/200802/beware_of_id_and_name_attribute_mixups_when_using_getelementbyid_in_internet_explorer/">http://www.456bereastreet.com/archive/200802/beware_of_id_and_name_attribute_mixups_when_using_getelementbyid_in_internet_explorer/</anchor-external>
(<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">名無しさん</anchor>)</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="13" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[13]</anchor-end> <cite>Bug 6006 - document.getElementById does not behave in the same way as Internet Explorer (Win)</cite> (<time>2008-11-29 18:07:10 +09:00</time> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://bugs.webkit.org/show_bug.cgi?id=6006">https://bugs.webkit.org/show_bug.cgi?id=6006</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="14" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[14]</anchor-end> <cite>Opera の id, name 問題 - IT戦記</cite> (<time>2009-02-02 02:01:48 +09:00</time> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="http://d.hatena.ne.jp/amachang/20071110/1194655704">http://d.hatena.ne.jp/amachang/20071110/1194655704</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="15" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[15]</anchor-end> <cite>Document Structure – SVG 1.1 (Second Edition)</cite>
( (<time>2011-08-10 12:35:27 +09:00</time> 版))
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="http://www.w3.org/TR/2011/REC-SVG11-20110816/struct.html#__svg__SVGSVGElement__getElementById">http://www.w3.org/TR/2011/REC-SVG11-20110816/struct.html#__svg__SVGSVGElement__getElementById</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="16" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[16]</anchor-end> <cite><strong></strong>[<strong></strong>whatwg<strong></strong>]<strong></strong> Proposal: Adding methods like getElementById and getElementsByTagName to DocumentFragments</cite>
( (<time>2013-10-19 00:27:18 +09:00</time> 版))
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-October/041211.html">http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-October/041211.html</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="17" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[17]</anchor-end> <cite>Move getElementById() from Document to ParentNode (now applies to Elemen... · 1e953d1 · whatwg/dom</cite>
( (<time>2013-11-13 11:37:54 +09:00</time> 版))
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/whatwg/dom/commit/1e953d1b2205dbf0ca78af82e6fd7c59a04c347e">https://github.com/whatwg/dom/commit/1e953d1b2205dbf0ca78af82e6fd7c59a04c347e</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="18" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[18]</anchor-end> <cite>Move getElementById() from Document to ParentNode (now applies to Elemen... · 1e953d1 · whatwg/dom</cite>
( (<time>2013-12-27 06:47:39 +09:00</time> 版))
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/whatwg/dom/commit/1e953d1b2205dbf0ca78af82e6fd7c59a04c347e">https://github.com/whatwg/dom/commit/1e953d1b2205dbf0ca78af82e6fd7c59a04c347e</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="19" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[19]</anchor-end> <cite>Remove getElementById from Element. https://www.w3.org/Bugs/Public/show_... · f71d7de · whatwg/dom</cite>
( (<time>2013-12-27 06:56:51 +09:00</time> 版))
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/whatwg/dom/commit/f71d7de304e1ee25573279157dd6ce1c2aa2c4f2">https://github.com/whatwg/dom/commit/f71d7de304e1ee25573279157dd6ce1c2aa2c4f2</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="20" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[20]</anchor-end> <cite xml:lang="en-US">XML Binding Language (XBL) 2.0</cite>
( (<time>2007-03-16 22:20:16 +09:00</time> 版))
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="http://www.w3.org/TR/2007/CR-xbl-20070316/#getelementbyid">http://www.w3.org/TR/2007/CR-xbl-20070316/#getelementbyid</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="5" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[5]</anchor-end> <cite xml:lang="en">Restore SVGSVGElement.getElementById. Closes #182.</cite>
(<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">nikosandronikos</anchor>著, <time>2016-07-01 15:01:30 +09:00</time>)
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/w3c/svgwg/commit/b842fc3a1d2b5f5330220870e1a097a62e696868">https://github.com/w3c/svgwg/commit/b842fc3a1d2b5f5330220870e1a097a62e696868</anchor-external></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="6" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[6]</anchor-end> <cite xml:lang="en">for getElementById, clarify result when multiple elements have the sa…</cite>
(<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">nikosandronikos</anchor>著, <time>2016-07-04 09:48:38 +09:00</time>)
<anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="https://github.com/w3c/svgwg/commit/0d66a1092e66226e59f6868d234c83f64230318a">https://github.com/w3c/svgwg/commit/0d66a1092e66226e59f6868d234c83f64230318a</anchor-external></p></section></section></body></html>