teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

修正

2018/10/27 02:53

投稿

退会済みユーザー
answer CHANGED
@@ -1,9 +1,13 @@
1
- タグaであり、属性href を持っている要素を取得するというセレクタその要素を得られます。
1
+ **タグaであり、属性href を持っている要素を取得するというセレクタ**を使って<a href="....">...</a>という全要素を得られます。
2
+
2
3
  ※回答した後、気になっていろいろ試していたところ、**jQueryと生のJSで得られる結果が異なりました。**理由は調べていますが、その点注意してください。
4
+ ⇒調べた結果、ページによっては$がjQueryでないのが原因と思われます。
3
5
 
4
6
  ```javascript
5
- /*生のJavascript(全て)*/ document.querySelectorAll('a[href]')
7
+ document.querySelectorAll('a[href]'); // 生のJavascript
6
- /*jQuery(ひとつだけ?)*/ $("a[href]")
8
+ $("a[href]") // jQuery
7
9
  ```
8
10
 
11
+ 参考:
9
- 参考: [Category: Attribute - jQuery](https://api.jquery.com/category/selectors/attribute-selectors/)
12
+ [Category: Attribute - jQuery](https://api.jquery.com/category/selectors/attribute-selectors/)
13
+ [「jQuery」がちゃんと読み込まれているか確認したい](http://daredemopc.blog51.fc2.com/blog-entry-1254.html)

2

修正

2018/10/27 02:53

投稿

退会済みユーザー
answer CHANGED
@@ -1,8 +1,9 @@
1
1
  タグaであり、属性href を持っている要素を取得するというセレクタで、その要素を得られます。
2
- (※jQueryを利用した場合)
2
+ 回答した後、気になっていろいろ試していたところ、**jQueryと生のJSで得られる結果が異なりました。**理由は調べていますが、その点注意してください。
3
3
 
4
4
  ```javascript
5
+ /*生のJavascript(全て)*/ document.querySelectorAll('a[href]')
5
- $("a[href]")
6
+ /*jQuery(ひとつだけ?)*/ $("a[href]")
6
7
  ```
7
8
 
8
9
  参考: [Category: Attribute - jQuery](https://api.jquery.com/category/selectors/attribute-selectors/)

1

微修正

2018/10/27 02:37

投稿

退会済みユーザー
answer CHANGED
@@ -1,6 +1,8 @@
1
+ タグaであり、属性href を持っている要素を取得するというセレクタで、その要素を得られます。
2
+ (※jQueryを利用した場合)
3
+
1
4
  ```javascript
2
5
  $("a[href]")
3
6
  ```
4
7
 
5
- 参考:
6
- - [Category: Attribute - jQuery](https://api.jquery.com/category/selectors/attribute-selectors/)
8
+ 参考: [Category: Attribute - jQuery](https://api.jquery.com/category/selectors/attribute-selectors/)