回答編集履歴
2
ちょうせい
answer
CHANGED
@@ -13,4 +13,18 @@
|
|
13
13
|
});
|
14
14
|
});
|
15
15
|
</script>
|
16
|
+
```
|
17
|
+
|
18
|
+
# メニュー3とメニュー5を排他的に開く
|
19
|
+
```javascript
|
20
|
+
window.addEventListener('DOMContentLoaded', ()=>{
|
21
|
+
document.querySelectorAll('#nav li>span').forEach(x=>{
|
22
|
+
x.addEventListener('click',()=>{
|
23
|
+
[...document.querySelectorAll('.subnavigation-inner')].forEach(y=>{
|
24
|
+
if(y!==x.nextElementSibling.querySelector('.subnavigation-inner')) y.classList.remove('active',);
|
25
|
+
});
|
26
|
+
x.nextElementSibling.querySelector('.subnavigation-inner')?.classList.toggle('active');
|
27
|
+
});
|
28
|
+
});
|
29
|
+
});
|
16
30
|
```
|
1
chousei
answer
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
}
|
6
6
|
</style>
|
7
7
|
<script>
|
8
|
-
|
8
|
+
window.addEventListener('DOMContentLoaded', ()=>{
|
9
9
|
document.querySelectorAll('#nav li>span').forEach(x=>{
|
10
|
-
x.addEventListener('click',
|
10
|
+
x.addEventListener('click',()=>{
|
11
11
|
x.nextElementSibling.querySelector('.subnavigation-inner')?.classList.toggle('active');
|
12
12
|
});
|
13
13
|
});
|