回答編集履歴

5

「引数」と「返り値」のコード追記

2017/11/26 08:43

投稿

think49
think49

スコア18164

test CHANGED
@@ -82,7 +82,17 @@
82
82
 
83
83
 
84
84
 
85
+ 「セレクタそのもの」にメソッドが生えているわけではありません。
86
+
87
+
88
+
89
+ ```JavaScript
90
+
85
- `"#foo"` と `jQuery('#foo')` は等価はありません。
91
+ jQuery('#foo').addClass('bar'); // 実行きる
92
+
93
+ '#foo'.addClass('bar'); // TypeError: "#foo".addClass is not a function
94
+
95
+ ```
86
96
 
87
97
 
88
98
 

4

引数と返り値

2017/11/26 08:43

投稿

think49
think49

スコア18164

test CHANGED
@@ -74,4 +74,24 @@
74
74
 
75
75
 
76
76
 
77
+ ### 関数の「引数」と「返り値」
78
+
79
+
80
+
81
+ > セレクタ.メソッド(引数)
82
+
83
+
84
+
85
+ `"#foo"` と `jQuery('#foo')` は等価ではありません。
86
+
87
+
88
+
89
+ 関数の「引数値」と「返り値」の違いから意識して、学習してみると良いと思います。
90
+
91
+
92
+
93
+ - [関数 引数 返り値 javascript - Google 検索](https://www.google.co.jp/search?q=%E9%96%A2%E6%95%B0+%E5%BC%95%E6%95%B0+%E8%BF%94%E3%82%8A%E5%80%A4&ie=UTF-8)
94
+
95
+
96
+
77
97
  Re: yamagata_user さん

3

コードを追記

2017/11/26 08:38

投稿

think49
think49

スコア18164

test CHANGED
@@ -22,6 +22,18 @@
22
22
 
23
23
 
24
24
 
25
+ セレクタとは「DOM上から対象の要素ノード」または「NodeList(ノードのリスト)」を検索する為の文字列であり、セレクタで条件を指定すれば目的のノードを得ることが出来ます。
26
+
27
+
28
+
29
+ ### コード
30
+
31
+
32
+
33
+ JavaScriptでは次のコードでセレクタを指定できます。
34
+
35
+
36
+
25
37
  ```JavaScript
26
38
 
27
39
  document.querySelector('#foo');
@@ -32,7 +44,33 @@
32
44
 
33
45
 
34
46
 
47
+ `jQuery()` は `querySelectorAll()` と同等の機能を持つので、次のように書きます。
48
+
49
+
50
+
51
+ ```JavaScript
52
+
53
+ jQuery('#foo')
54
+
55
+ jQuery('#bar>.piyo>p');
56
+
57
+ ```
58
+
59
+
60
+
35
- セレクタ「DOM上から対象の要素ノード」まは「NodeList(ノードリスト)」を検索する為の文字列であり、セレクタで条件指定すれば目的のノードを得ること出来ま
61
+ JavaScriptコード上に存在するセレクタは、**の文字列(String値)**であり、専用に用意された関数通さなければ目的のノードを得ること出来ません
62
+
63
+
64
+
65
+ ```JavaScript
66
+
67
+ "#foo"; // セレクタ (ただの文字列)
68
+
69
+ document.querySelector('#foo'); // 要素ノードを返す
70
+
71
+ jQuery('#foo'); // jQueryオブジェクトを返す
72
+
73
+ ```
36
74
 
37
75
 
38
76
 

2

引用文の追記

2017/11/26 08:33

投稿

think49
think49

スコア18164

test CHANGED
@@ -6,9 +6,17 @@
6
6
 
7
7
 
8
8
 
9
- - [Selectors Level 4 (日本語訳)](https://triple-underscore.github.io/selectors4-ja.html)
9
+ - [2. 選択子の概観 - Selectors Level 4](https://triple-underscore.github.io/selectors4-ja.html#overview)
10
+
11
+ - [2. Selectors Overview - Selectors Level 4](https://www.w3.org/TR/selectors4/#overview)
10
12
 
11
13
 
14
+
15
+ > A Selector represents a structure. This structure can be used as a condition (e.g. in a CSS rule) that determines which elements a selector matches in the document tree, or as a flat description of the HTML or XML fragment corresponding to that structure.
16
+
17
+
18
+
19
+ 日本語訳「選択子(Selector)は、構造を表現する。 この構造は、文書木の中でどの要素が選択子に合致するかを決定するための条件として(例えば CSS 規則における), あるいは その構造に対応する HTML や XML の素片の flat な記述として,利用し得る。」
12
20
 
13
21
  CSSでの利用用途が有名ですが、JavaScriptでも `querySelector`, `querySelectorAll` で利用することが出来ます。
14
22
 

1

空白バグ対処

2017/11/26 08:09

投稿

think49
think49

スコア18164

test CHANGED
File without changes