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

質問編集履歴

3

整合性を直す

2018/04/05 06:26

投稿

poge
poge

スコア15

title CHANGED
File without changes
body CHANGED
@@ -20,7 +20,7 @@
20
20
  ### 発生している問題・エラーメッセージ
21
21
  以下のような謎の現象が発生します。
22
22
  0. タッチする前、タッチ対象の要素のクラスは「target-class」のみ(touchedクラスは設定されていない)
23
- 0. タッチを行い、タッチイベントが発生し、冒頭のevent.preventDefault()でブレイクすると、何故か$(this)のクラスは「target-class touched」になっている(touchedが付与されている)
23
+ 0. タッチを行い、タッチイベントが発生し、冒頭のhasClass('touched')でブレイクすると、何故か$(this)のクラスは「target-class touched」になっている(touchedが付与されている)
24
24
  0. 上記事象により、初回タッチ時に、$(this).hasClass('touched') === trueが正になり、ulが表示されない
25
25
 
26
26
  ### 試したこと

2

evtを削除

2018/04/05 06:26

投稿

poge
poge

スコア15

title CHANGED
File without changes
body CHANGED
@@ -5,9 +5,7 @@
5
5
  ### 実現したいこと
6
6
  以下のコードにより、タッチイベント毎にulの表示をトグルしようとしています。
7
7
  ```javascript
8
- $('.target-class').on('touchstart', function(evt) {
8
+ $('.target-class').on('touchstart', function() {
9
- event.preventDefault();
10
-
11
9
  if ( $(this).hasClass('touched') === true){
12
10
  $(this).removeClass('touched');
13
11
  $(this).find('ul').slideDown(500, 'easeOutExpo');

1

誤字訂正

2018/04/05 02:10

投稿

poge
poge

スコア15

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,7 @@
3
3
  確認環境:GoogleChrome(65.0.3325.181) Developer ToolsのデバイスモードでiPhone5をエミュレートしています
4
4
 
5
5
  ### 実現したいこと
6
- 以下のコードにより、タッチイベント毎にulの表示をトグルしのでが、
6
+ 以下のコードにより、タッチイベント毎にulの表示をトグルしようとして
7
7
  ```javascript
8
8
  $('.target-class').on('touchstart', function(evt) {
9
9
  event.preventDefault();