回答編集履歴

3

追記

2019/01/25 10:56

投稿

yambejp
yambejp

スコア114839

test CHANGED
@@ -20,4 +20,46 @@
20
20
 
21
21
  ```
22
22
 
23
+ # 追記
24
+
25
+ navi以外をクリックするとnaviを閉じる
26
+
27
+ ```javascript
28
+
29
+ $(function(){
30
+
31
+ $("#nav ul").addClass("close");
32
+
33
+ $(document).find('*').on('click',function(e){
34
+
35
+ if($(this).closest('#nav').length==0){
36
+
37
+ $("#nav ul").addClass('close');
38
+
39
+ $("#nav .slidebtn>a").css('background-Color','');
40
+
23
- ※一部調整
41
+ }else{
42
+
43
+ e.stopPropagation();
44
+
45
+ }
46
+
47
+ });
48
+
49
+ $("#nav .slidebtn>a").on('click',function(e){
50
+
51
+ e.preventDefault();
52
+
53
+ $(this).next('ul').toggleClass("close");
54
+
55
+ $(this).css('background-Color',$(this).next('ul').hasClass("close")?'':'#E6E6E6');
56
+
57
+ $(this).closest('li').siblings().find('ul').addClass("close").prev('a').css('background-Color','');
58
+
59
+ });
60
+
61
+ });
62
+
63
+
64
+
65
+ ```

2

調整2

2019/01/25 10:56

投稿

yambejp
yambejp

スコア114839

test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  e.preventDefault();
10
10
 
11
- $(this).closest('li').find('ul').toggleClass("close");
11
+ $(this).next('ul').toggleClass("close");
12
12
 
13
13
  $(this).css('background-Color',$(this).next('ul').hasClass("close")?'':'#E6E6E6');
14
14
 

1

調整

2019/01/25 09:57

投稿

yambejp
yambejp

スコア114839

test CHANGED
@@ -12,12 +12,12 @@
12
12
 
13
13
  $(this).css('background-Color',$(this).next('ul').hasClass("close")?'':'#E6E6E6');
14
14
 
15
- $(this).closest('li').siblings().find('ul').addClass("close");
16
-
17
- $(this).closest('li').siblings().find('>a').css('background-Color','');
15
+ $(this).closest('li').siblings().find('ul').addClass("close").prev('a').css('background-Color','');
18
16
 
19
17
  });
20
18
 
21
19
  });
22
20
 
23
21
  ```
22
+
23
+ ※一部調整