回答編集履歴
1
途中で投稿してしまったので修正。
test
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
|
11
11
|
console.log($(event.currentTarget));
|
12
12
|
|
13
|
+
//省略
|
14
|
+
|
13
15
|
|
14
16
|
|
15
17
|
```
|
@@ -20,12 +22,24 @@
|
|
20
22
|
|
21
23
|
|
22
24
|
|
25
|
+
実装例
|
26
|
+
|
23
27
|
```html
|
24
28
|
|
25
|
-
<button id = "ymc
|
29
|
+
<button id = "ymc1" class="ymc" data-id="1">ボタン</button>
|
26
30
|
|
27
|
-
<button id = "ymc
|
31
|
+
<button id = "ymc2" class="ymc" data-id="2">ボタン</button>
|
28
32
|
|
29
|
-
<button id = "ymc
|
33
|
+
<button id = "ymc3" class="ymc" data-id="3">ボタン</button>
|
30
34
|
|
31
35
|
```
|
36
|
+
|
37
|
+
```js
|
38
|
+
|
39
|
+
$(".ymc").on("click",function(event){
|
40
|
+
|
41
|
+
console.log($(event.currentTarget).data("id"));
|
42
|
+
|
43
|
+
//省略
|
44
|
+
|
45
|
+
```
|