回答編集履歴
1
追記
test
CHANGED
@@ -15,3 +15,69 @@
|
|
15
15
|
}).call (document.getElementById('cat-img'));
|
16
16
|
|
17
17
|
```
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
もし以下のコードの意図がわかってくれるなら・・・
|
22
|
+
|
23
|
+
イベントはルートで監視する
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
```js
|
28
|
+
|
29
|
+
<!DOCTYPE html>
|
30
|
+
|
31
|
+
<meta charset="utf-8"><html>
|
32
|
+
|
33
|
+
<title></title>
|
34
|
+
|
35
|
+
<style>
|
36
|
+
|
37
|
+
p { position: absolute; }
|
38
|
+
|
39
|
+
</style>
|
40
|
+
|
41
|
+
<body>
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
<script>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
const {PI, sin, cos} = Math, D = PI / 6;
|
50
|
+
|
51
|
+
for (let i = 1; i < 13; i++) {
|
52
|
+
|
53
|
+
let p = document.body.appendChild (document.createElement ('p'));
|
54
|
+
|
55
|
+
p.textContent = i;
|
56
|
+
|
57
|
+
p.style.top = (100 - cos (i * D) * 100 |0) + 'px';
|
58
|
+
|
59
|
+
p.style.left = (100 + sin (i * D) * 100 |0) +'px';
|
60
|
+
|
61
|
+
p.id = 'p' + i;
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
document.addEventListener('mouseover', (event) => {
|
70
|
+
|
71
|
+
let e = event.target;
|
72
|
+
|
73
|
+
e.id && console.log(e.id);
|
74
|
+
|
75
|
+
});
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
</script>
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
```
|