回答編集履歴
2
追記
test
CHANGED
@@ -2,11 +2,59 @@
|
|
2
2
|
|
3
3
|
```jQuery
|
4
4
|
|
5
|
-
$('a').on('click', function(){
|
6
5
|
|
7
|
-
body.classList.remove('nav_open');
|
8
6
|
|
7
|
+
(function ($) {
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
/* ------------------------------- */
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
})(jQuery);
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
/* SP menu */
|
24
|
+
|
25
|
+
function toggleNav() {
|
26
|
+
|
27
|
+
var body = document.body;
|
28
|
+
|
29
|
+
var hamburger = document.getElementById('nav_btn');
|
30
|
+
|
31
|
+
var blackBg = document.getElementById('nav_bg');
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
hamburger.addEventListener('click', function() {
|
36
|
+
|
37
|
+
body.classList.toggle('nav_open'); //メニュークリックでnav-openというクラスがbodyに付与
|
38
|
+
|
9
|
-
});
|
39
|
+
});
|
40
|
+
|
41
|
+
blackBg.addEventListener('click', function() {
|
42
|
+
|
43
|
+
body.classList.remove('nav_open'); //もう一度クリックで解除
|
44
|
+
|
45
|
+
});
|
46
|
+
|
47
|
+
$('a').on('click', function(){
|
48
|
+
|
49
|
+
body.classList.remove('nav_open');
|
50
|
+
|
51
|
+
});
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
toggleNav();
|
56
|
+
|
57
|
+
|
10
58
|
|
11
59
|
```
|
12
60
|
|
1
追記
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
body.classList.remove('nav_open');
|
8
8
|
|
9
|
-
}
|
9
|
+
});
|
10
10
|
|
11
11
|
```
|
12
12
|
|