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

回答編集履歴

3

リンクがallになっていなかったので修正。

2017/10/05 01:19

投稿

masaya_ohashi
masaya_ohashi

スコア9210

answer CHANGED
@@ -1,5 +1,5 @@
1
1
  `document.querySelectorAll`を使えば一発です。cssのセレクタ記法と同様の書き方で、elementのリストが取得できます。
2
- [https://developer.mozilla.org/ja/docs/Web/API/Document/querySelector](https://developer.mozilla.org/ja/docs/Web/API/Document/querySelector)
2
+ [https://developer.mozilla.org/ja/docs/Web/API/Document/querySelectorAll](https://developer.mozilla.org/ja/docs/Web/API/Document/querySelectorAll)
3
3
 
4
4
  ```javascript
5
5
  var touchList = document.querySelectorAll("#application li img");

2

querySelectorでは1個しか取れないのでAllに変更

2017/10/05 01:19

投稿

masaya_ohashi
masaya_ohashi

スコア9210

answer CHANGED
@@ -1,6 +1,6 @@
1
- `document.querySelector`を使えば一発です。cssのセレクタ記法と同様の書き方で、elementのリストが取得できます。
1
+ `document.querySelectorAll`を使えば一発です。cssのセレクタ記法と同様の書き方で、elementのリストが取得できます。
2
2
  [https://developer.mozilla.org/ja/docs/Web/API/Document/querySelector](https://developer.mozilla.org/ja/docs/Web/API/Document/querySelector)
3
3
 
4
4
  ```javascript
5
- var touchList = document.querySelector("#application li img");
5
+ var touchList = document.querySelectorAll("#application li img");
6
6
  ```

1

コードブロックに言語表記を追加。

2017/10/05 01:18

投稿

masaya_ohashi
masaya_ohashi

スコア9210

answer CHANGED
@@ -1,6 +1,6 @@
1
1
  `document.querySelector`を使えば一発です。cssのセレクタ記法と同様の書き方で、elementのリストが取得できます。
2
2
  [https://developer.mozilla.org/ja/docs/Web/API/Document/querySelector](https://developer.mozilla.org/ja/docs/Web/API/Document/querySelector)
3
3
 
4
- ```
4
+ ```javascript
5
5
  var touchList = document.querySelector("#application li img");
6
6
  ```