質問編集履歴
2
実際記述しているJSソースを追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -62,3 +62,67 @@
|
|
62
62
|
|
63
63
|
よろしくお願いいたします。
|
64
64
|
|
65
|
+
|
66
|
+
|
67
|
+
### 追記
|
68
|
+
|
69
|
+
ポップアップの設定は以下のように行っています。
|
70
|
+
```javascript
|
71
|
+
/*--Informationのポップアップ--*/
|
72
|
+
const popupTtl = document.querySelectorAll('.tinfo-ttl');
|
73
|
+
const popupBox = document.querySelectorAll('.info-content);
|
74
|
+
const popupCloseBtn = document.querySelectorAll(
|
75
|
+
'.top-info-content-popup-close-btn'
|
76
|
+
);
|
77
|
+
const popupContentBg = document.querySelectorAll(
|
78
|
+
'.top-info-content-popup-inner-box'
|
79
|
+
);
|
80
|
+
|
81
|
+
window.addEventListener('DOMContentLoaded', function () {
|
82
|
+
for (let i = 0; i < popupTtl.length; i++) {
|
83
|
+
popupTtl[i].addEventListener('click', function (e) {
|
84
|
+
e.preventDefault();
|
85
|
+
let dataPopupTtl = popupTtl[i].getAttribute('data-popup-ttl');
|
86
|
+
for (let j = 0; j < popupBox.length; j++) {
|
87
|
+
if (popupBox[j].getAttribute('data-popup-cont') === dataPopupTtl) {
|
88
|
+
popupBox[j].classList.add('active');
|
89
|
+
}
|
90
|
+
}
|
91
|
+
});
|
92
|
+
popupContentBg[i].addEventListener('click', function () {
|
93
|
+
popupBox[i].classList.add('active2');
|
94
|
+
setTimeout(function () {
|
95
|
+
popupBox[i].classList.remove('active');
|
96
|
+
popupBox[i].classList.remove('active2');
|
97
|
+
}, 300);
|
98
|
+
});
|
99
|
+
popupCloseBtn[i].addEventListener('click', function () {
|
100
|
+
popupBox[i].classList.add('active2');
|
101
|
+
setTimeout(function () {
|
102
|
+
popupBox[i].classList.remove('active');
|
103
|
+
popupBox[i].classList.remove('active2');
|
104
|
+
}, 300);
|
105
|
+
});
|
106
|
+
}
|
107
|
+
});
|
108
|
+
|
109
|
+
//Informationポップアップを開いてる時にスクロール禁止
|
110
|
+
const scrollProhabitedBody = document.getElementsByTagName('body');
|
111
|
+
|
112
|
+
popupTtl.forEach(function (info) {
|
113
|
+
info.addEventListener('click', function () {
|
114
|
+
popupBox.forEach(function (element) {
|
115
|
+
if (element.classList.contains('active')) {
|
116
|
+
scrollProhabitedBody.classList.add('modal-open');
|
117
|
+
} else {
|
118
|
+
scrollProhabitedBody.classList.remove('modal-open');
|
119
|
+
}
|
120
|
+
});
|
121
|
+
});
|
122
|
+
});
|
123
|
+
|
124
|
+
```
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
1
「該当箇所にclassを付与」の部分をわかりやすく変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
### 実現したいこと
|
5
5
|
インフォーメーションを設定しており、クリックした内容をポップアップで表示させています。
|
6
6
|
その時に、背後をスクロール禁止にしたいです。
|
7
|
-
|
7
|
+
class="info-ttl"をクリックしたときに、class="info-content"にクラス名activeが追加で付くように設定しています。
|
8
8
|
|
9
9
|
### 該当のソースコード
|
10
10
|
|