回答編集履歴
1
ちょうせい
test
CHANGED
@@ -17,3 +17,63 @@
|
|
17
17
|
```
|
18
18
|
|
19
19
|
なのでは?
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
# sample
|
24
|
+
|
25
|
+
```javascript
|
26
|
+
|
27
|
+
<script>
|
28
|
+
|
29
|
+
const he = ["aaa","bbb"];
|
30
|
+
|
31
|
+
const id = ["ccc","ddd"];
|
32
|
+
|
33
|
+
const name_ccc=()=>{
|
34
|
+
|
35
|
+
const n =0;
|
36
|
+
|
37
|
+
const result = document.querySelector('#'+id[n]);
|
38
|
+
|
39
|
+
result.textContent += "ccc";
|
40
|
+
|
41
|
+
const input = Object.assign(document.createElement("input"),{
|
42
|
+
|
43
|
+
type:"button",
|
44
|
+
|
45
|
+
value:"次へ",
|
46
|
+
|
47
|
+
});
|
48
|
+
|
49
|
+
input.addEventListener('click',name_aaa);
|
50
|
+
|
51
|
+
result.appendChild(input);
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
const name_aaa=()=>{
|
56
|
+
|
57
|
+
const n =0;
|
58
|
+
|
59
|
+
document.querySelector('#'+he[n]).textContent += "aaa";
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
window.addEventListener('DOMContentLoaded', ()=>{
|
64
|
+
|
65
|
+
he.map(x=>Object.assign(document.createElement('div'),{id:x})).reduce((x,y)=>(x.appendChild(y),x),document.querySelector("#head"));
|
66
|
+
|
67
|
+
id.map(x=>Object.assign(document.createElement('div'),{id:x})).reduce((x,y)=>(x.appendChild(y),x),document.querySelector("#result"));
|
68
|
+
|
69
|
+
name_ccc();
|
70
|
+
|
71
|
+
});
|
72
|
+
|
73
|
+
</script>
|
74
|
+
|
75
|
+
<div id="head"></div>
|
76
|
+
|
77
|
+
<div id="result"></div>
|
78
|
+
|
79
|
+
```
|