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

回答編集履歴

2

シングルクォーテーションとダブルクォーテーションが混在していたので統一した

2015/05/03 10:29

投稿

MAGP
MAGP

スコア153

answer CHANGED
@@ -1,8 +1,8 @@
1
1
  document.ontouchendはタッチをサポートする環境(※1)では初期値としてnullが入っており、
2
2
  サポートしない環境では定義されていないため、
3
- "ontouchend" in document(※2)で問題なく分岐できそうです
3
+ 'ontouchend' in document(※2)で問題なく分岐できそうです
4
4
  ```lang-javascript
5
- if ("ontouchend" in document) {
5
+ if ('ontouchend' in document) {
6
6
  // タッチ用
7
7
  } else {
8
8
  // マウス用
@@ -12,7 +12,7 @@
12
12
  あと分岐ですがイベント名の方を分岐するというのもよくやりますね。
13
13
  ```lang-javascript
14
14
  var EVENTNAME_TOUCHSTART, EVENTNAME_TOUCHMOVE, EVENTNAME_TOUCHEND;
15
- if ("ontouchend" in document) {
15
+ if ('ontouchend' in document) {
16
16
  EVENTNAME_TOUCHSTART = 'touchstart';
17
17
  EVENTNAME_TOUCHMOVE = 'touchmove';
18
18
  EVENTNAME_TOUCHEND = 'touchend';

1

注釈マーク位置修正

2015/05/03 10:29

投稿

MAGP
MAGP

スコア153

answer CHANGED
@@ -1,6 +1,6 @@
1
1
  document.ontouchendはタッチをサポートする環境(※1)では初期値としてnullが入っており、
2
2
  サポートしない環境では定義されていないため、
3
- "ontouchend" in documentで問題なく分岐できそうです(※2)
3
+ "ontouchend" in document(※2)で問題なく分岐できそうです
4
4
  ```lang-javascript
5
5
  if ("ontouchend" in document) {
6
6
  // タッチ用