回答編集履歴

1

getElementsByTagName が存在する Interface について

2017/04/05 06:05

投稿

think49
think49

スコア18166

test CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
 
4
4
 
5
+ > ```JavaScript
6
+
5
7
  > var x = document.getElementsByClassName(クラス名).getElementsByTagName("a");
8
+
9
+ > ```
6
10
 
7
11
 
8
12
 
@@ -10,11 +14,15 @@
10
14
 
11
15
  HTMLCollection には `getElementsByTagName` は生えていませんので、そのコードはエラーになります。
12
16
 
17
+ getElementsByTagName は `Document.prototype.getElementsByTagName` もしくは `Element.prototype.getElementsByTagName` に存在しますので、対象が `document` オブジェクトもしくは要素ノードでなければ使用できません。
18
+
13
19
 
14
20
 
15
21
  - [3.5. インタフェース Document - DOM Standard 日本語訳](https://triple-underscore.github.io/DOM4-ja.html#interface-document)
16
22
 
23
+ - [3.9. インタフェース Element - DOM Standard 日本語訳](https://triple-underscore.github.io/DOM4-ja.html#interface-element)
17
24
 
25
+ - [3.2.10.2. インタフェース HTMLCollection - DOM Standard 日本語訳](https://triple-underscore.github.io/DOM4-ja.html#interface-htmlcollection)
18
26
 
19
27
 
20
28