回答編集履歴
1
chousei
test
CHANGED
@@ -27,3 +27,33 @@
|
|
27
27
|
<div>ccc</div>
|
28
28
|
|
29
29
|
```
|
30
|
+
|
31
|
+
もっと単純に書くなら
|
32
|
+
|
33
|
+
```javascript
|
34
|
+
|
35
|
+
<script>
|
36
|
+
|
37
|
+
window.addEventListener('DOMContentLoaded', function(e){
|
38
|
+
|
39
|
+
[].forEach.call(document.querySelectorAll("div"),function(x){
|
40
|
+
|
41
|
+
x.addEventListener("click", function(){
|
42
|
+
|
43
|
+
this.classList.add("add");
|
44
|
+
|
45
|
+
});
|
46
|
+
|
47
|
+
});
|
48
|
+
|
49
|
+
});
|
50
|
+
|
51
|
+
</script>
|
52
|
+
|
53
|
+
<div>aaa</div>
|
54
|
+
|
55
|
+
<div>bbb</div>
|
56
|
+
|
57
|
+
<div>ccc</div>a
|
58
|
+
|
59
|
+
```
|