回答編集履歴
1
chousei
test
CHANGED
@@ -4,3 +4,27 @@
|
|
4
4
|
console.log(list);
|
5
5
|
});
|
6
6
|
```
|
7
|
+
クラスをつけるならこう?
|
8
|
+
```javascript
|
9
|
+
<script>
|
10
|
+
window.addEventListener('DOMContentLoaded', ()=>{
|
11
|
+
document.querySelectorAll('li').forEach(x=>{
|
12
|
+
x.classList.add(`row_${x.closest('ul').querySelectorAll('li').length}`);
|
13
|
+
});
|
14
|
+
});
|
15
|
+
</script>
|
16
|
+
<ul class="BoxList">
|
17
|
+
<li class="LIst"><span><img src=""></span></li>
|
18
|
+
<li class="LIst"><span><img src=""></span></li>
|
19
|
+
<li class="LIst"><span><img src=""></span></li>
|
20
|
+
<li class="LIst"><span><img src=""></span></li>
|
21
|
+
</ul>
|
22
|
+
|
23
|
+
<ul class="BoxList">
|
24
|
+
<li class="LIst"><span><img src=""></span></li>
|
25
|
+
<li class="LIst"><span><img src=""></span></li>
|
26
|
+
<li class="LIst"><span><img src=""></span></li>
|
27
|
+
<li class="LIst"><span><img src=""></span></li>
|
28
|
+
<li class="LIst"><span><img src=""></span></li>
|
29
|
+
</ul>
|
30
|
+
```
|